0

I have a javascript code, i don't know what exactly that code does. I was told to execute that script on a button click and that worked fine.

But i need to run that script on another tab, actually they want that when button is clicked it should open another tab and that script should run on new tab.I am using this code to run the script on another page and it's not working.

<INPUT class="input_style15" type=submit value="Enter" onclick="window.open(test_script());" name=get_button>

when button is clicked, it shows the error- HTTP 404 page not found.

Need help, Thanks in advance.

Mogli
  • 1,946
  • 11
  • 33
  • 63
  • What does `test_script()` return? – Mr. Alien Sep 17 '13 at 08:34
  • @한국매미 매미 You can if you have opened that tab (window) yourself and it's of the same origin. – pawel Sep 17 '13 at 08:37
  • @pawel I take that back :) Marked as [dupe](http://stackoverflow.com/questions/3772535/open-a-new-window-and-call-javascript-function), also. – user703016 Sep 17 '13 at 08:38
  • I don't think it will call. The function should have to be present in the open window document. You need to pass that function body and than you need to call that function. – pixelbyaj Sep 17 '13 at 08:42
  • [This answer](https://stackoverflow.com/questions/18844982/how-to-execute-javascript-on-another-page) might help you. – iamabdm Oct 13 '21 at 10:36

1 Answers1

0

window.open() is explained in the attached link.

You need to provide us with more details on the javascript function test_script() to be able to assist you more.

Here is also a good example of your question being answered on how to use window.open() - hope it helps :) How to open a new window and insert html into it using jQuery?

Community
  • 1
  • 1
mcv
  • 1,292
  • 2
  • 16
  • 41