переход на страницу и клик по id
can you help me? i need to open the page and then do 'click' by 'id' (P.S. all in anchor) onclick="window.open('mono.html').click(document.g etElementById('p26'))" //wrong but graphically :)
|
If you do not have access to editing the file mono.html, in any way. And if there is, then add the script to a file
if (window.location.hash) {
var target = window.location.hash.replace('#', '');
document.getElementById(target).click();
}
and just call this
window.open('mono.html#p26')
|
var hash = window.location.hash;
if(hash) {
var elem = document.getElementById(hash.substr(1));
if(elem) elem.click();
}
И почему название темы по русски, а пост по англ.? |
Цитата:
|
stereo.html
<!DOCTYPE html>
<html><head></head>
<body>
<script>
newWindow = window.open('mono.html');
newWindow.addEventListener('load', function() {
var el = newWindow.document.getElementById('p26');
if(el) el.click();
}, false);
</script>
</body>
</html>
mono.html
<!DOCTYPE html>
<html><head></head>
<body>
<a id="p26" href="#" onclick="alert('yes!'); return false">yes?</a>
</body>
</html>
|
| Часовой пояс GMT +3, время: 13:06. |