Javascript-форум (https://javascript.ru/forum/)
-   Элементы интерфейса (https://javascript.ru/forum/dom-window/)
-   -   переход на страницу и клик по id (https://javascript.ru/forum/dom-window/41252-perekhod-na-stranicu-i-klik-po-id.html)

pumaone 05.09.2013 22:00

переход на страницу и клик по 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 :)

BETEPAH 05.09.2013 22:42

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')

ruslan_mart 06.09.2013 05:03

var hash = window.location.hash;
if(hash) {
   var elem = document.getElementById(hash.substr(1));
   if(elem) elem.click();
}


И почему название темы по русски, а пост по англ.?

ksa 06.09.2013 09:46

Цитата:

Сообщение от Ruslan_xDD
почему название темы по русски, а пост по англ.?

Eto test! :D

BETEPAH 06.09.2013 10:44

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, время: 03:50.