How to open a webpage and run some javascript functions?

Hi, I would like to open a page and then run some javascript functions. My problem is that as soon as I open the window, it will stop running the code:

javascript:
location=("http://www.myTestPage.com/");
showForm();
document.getElementById("txtEmail").value="test@hotmail.com";
submit();
+3
source share
5 answers

You can not. The problem is that each page loads in its own logical window (even if this window occupies the same client area in the browser as the previous page). Each window runs a script in its own context. Usually, when windows are replaced, any running script exits, and even if I didn’t suspect that you want the code following the location to work on the new content.

. dyanmically - PHP ASP, , , SRC script, .

+4

, javascript window. location = . , . , , .

+2

, . , javascript.

+2

location=("http://www.myTestPage.com/") . showForm()? , , ?

, , , ?

window.open("http://www.myTestPage.com/"); 
showForm(); 
document.getElementById("txtEmail").value="test@hotmail.com"; 
submit();

:

, , . :

  • .

  • ,

+1

JavaScript, ( JavaScript ); , , .

+1

Source: https://habr.com/ru/post/1720958/


All Articles