Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autobrowse in Javascript? 2

Status
Not open for further replies.
You don't even need JS to do this. You can simply create a series of HTML files to load in a full window frame of the target web site, then use the meta refresh tag to call the next HTML file that frames another target web site.

For the example shown on the link you provided, you could make these two HTML files.

Code:
<!-- autobrowse1.html -->
<html>
	<head>
		<meta http-equiv="refresh" content="10; url=autobrowse2.html">
		<title>AutoBrowse</title>
	</head>
	<frameset cols="*" border="0" frameborder="no" framespacing="0">
		<frame name="myFrame" src="[URL unfurl="true"]https://www.bbc.co.uk"[/URL] />
	</frameset>
</html>


<!-- autobrowse2.html -->
<html>
	<head>
		<meta http-equiv="refresh" content="20; url=autobrowse1.html">
		<title>AutoBrowse</title>
	</head>
	<frameset cols="*" border="0" frameborder="no" framespacing="0">
		<frame name="myFrame" src="[URL unfurl="true"]https://www.google.com"[/URL] />
	</frameset>
</html>
 
Hi

To be noted that such solutions works only if you administrate the given sites. Because they[ul]
[li]Must not contain frame breaker code ( [tt]this[teal].[/teal]top[teal].[/teal]location [teal]!==[/teal] this[teal].[/teal]location [teal]&& ([/teal]this[teal].[/teal]top[teal].[/teal]location [teal]=[/teal] this[teal].[/teal]location[teal])[/teal][/tt] )[/li]
[li]Must send [tt]X-Frame-Options[/tt] HTTP response header ( otherwise you will hit "Load denied by X-Frame-Options: does not permit cross-origin framing." error )[/li]
[/ul]


Feherke.
feherke.github.io
 
Hi Spamjim, I have tried that before I posted here but it didn't work like what Feherke said. The page won't load, it's been denied.
 
JS won't do any better because it is constrained by the same limitations. This is why you'd need an external program such as AutoBrowse or some 'automated testing tool' to drive the change in URL requests for the browser.

Is there interest in explaining the intended application? There's probably a better solution.
 
Hi

Indeed, you will need a bit more permissions than regular document level JavaScript has. But a user script may be enough, though the control will be pretty weak :
Code:
[gray]// ==UserScript==[/gray]
[gray]// @name        AutoBrowse[/gray]
[gray]// @grant       none[/gray]
[gray]// ==/UserScript==[/gray]

[b]var[/b] play_list [teal]= [[/teal]
  [teal]{[/teal]url[teal]:[/teal] [i][green]'[URL unfurl="true"]https://www.bbc.com/'[/URL][/green][/i][teal],[/teal] wait[teal]:[/teal] [purple]10[/purple][teal]},[/teal]
  [teal]{[/teal]url[teal]:[/teal] [i][green]'[URL unfurl="true"]https://www.google.com/'[/URL][/green][/i][teal],[/teal] wait[teal]:[/teal] [purple]20[/purple][teal]},[/teal]
[teal]][/teal]

[b]if[/b] [teal]([/teal]self [teal]==[/teal] top[teal])[/teal]
  [b]for[/b] [teal]([/teal][b]var[/b] i [teal]=[/teal] [purple]0[/purple][teal],[/teal] l [teal]=[/teal] play_list[teal].[/teal]length[teal];[/teal] i [teal]<[/teal] l[teal];[/teal] i[teal]++)[/teal]
    [b]if[/b] [teal]([/teal]play_list[teal][[/teal]i[teal]].[/teal]url [teal]==[/teal] location[teal].[/teal]href[teal]) {[/teal]
      [COLOR=orange]setTimeout[/color][teal]([/teal][b]function[/b][teal]() {[/teal] location[teal].[/teal]href [teal]=[/teal] play_list[teal][([/teal]i [teal]+[/teal] [purple]1[/purple][teal]) %[/teal] l[teal]].[/teal]url [teal]},[/teal] play_list[teal][[/teal]i[teal]].[/teal]wait [teal]*[/teal] [purple]1000[/purple][teal])[/teal]
      [b]break[/b]
    [teal]}[/teal]
[ul]
[li]Tested in pretty old FireFox with GreaseMonkey extension. May need adjustments in newer browsers.[/li]
[li]After installing the user script, just visit any of the addresses enumerated in the play_list, and the user script will set a redirection to the next one, and so on.[/li]
[li]Note that if any of the listed URLs will redirect ( http to https, no www. to www. or anything else ), the redirection chain will be broken.[/li]
[/ul]


Feherke.
feherke.github.io
 
Geewhiz...that works perfectly in modern FF and Greasemonkey.


 
Use HTML files to do that. Java is not needed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top