How can I use my same JavaScript code on a newly loaded page (from a redirect) -


i trying emulate user experience on multiple websites, want single script redirect new website, start scrolling bottom, , go original site. here code, loads page fine not scroll.

<html> <head> <title>benchmark</title> <script type="text/javascript"> function loadurl(newlocation) {   window.location = newlocation;   window.onload=pagescroll; }   function pagescroll() {         window.scrollby(0,50); // horizontal , vertical scroll increments         scrolldelay = settimeout('pagescroll()',100); // scrolls every 100 milliseconds } </script> </head> <body> <a href="javascript:void" onclick="loadurl('anysite.com'); return false;">link-1</a> </body> </html> 

i have not gotten redirect page, doesn't matter yet. thanks!

there number of problems prevent working:

  1. when set window location new url (regardless of being external or not), javascript on current page stops executing. won't have access new page it's been replaced (it's unloaded). so, means "window.onload" code never called. new page active.
  2. if tried iframe approach , loaded external page iframe, not work code cannot access internal web page (and scrollby function) if web site different domain. might read this more information security feature. if external page web server: www.example.com, , internal content www.microsoft.com, scripts (and scrolling code) in www.example.com not able scroll document.

there number of freely available scripting/automation tools can provide better , 100% reliable simulation of user. 1 example telerik. might want @ depending on you're trying accomplish.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -