...

View Full Version : Popup/Frame Control



VastCode
08-17-2005, 03:31 PM
I am very new to Javascript, and I do not intend on learning it. I am a PHP/SQL coder, and am looking to do something with Javascript, as I see it as the best way.

I want to be able to control a Javascript popup window, or frame within the page.

Let's say I have a popup window. Let's call this POPUP1. What I want POPUP1 to do, is simple. I want to be able to declare all it's properties.

Specifically, what I am looking to do, is this:

POPUP1 should open up, and navigate to http://site1.com. In x amount of seconds, I want POPUP1 to navigate to http://site2.com. This should all happen in one local popup window.

I am sure that this is all very simple! It'd appriciate it if someone could also teach me how to do this with frames/iframes, with the same specification, but calling it FRAME1.

Thanks alot,

- VC

Mr J
08-17-2005, 07:36 PM
Will the opener still be loaded while the popup is open?

If so you could possibly go like this


<HTML>
<HEAD>
<TITLE>Document Title</TITLE>

<script type="text/javascript">
<!--

urls=new Array()
urls[0]="http://www.codebrain.com"
urls[1]="http://www.hrgiger.com"
urls[2]="http://www.joecartoon.com"
urls[3]="http://www.dhtmlnirvana.com"

time=5000
count=0

function openWin(){
newWin=window.open(urls[count],'win1','left=100,top=100,width=600,height=400')
setTimeout("nextUrl()",time)
}

function nextUrl(){

if(newWin&&newWin.open&&!newWin.closed){
count++

if(count==urls.length){
count=0
}

newWin.location=urls[count]

setTimeout("nextUrl()",time)
}
}

//-->
</script>
</HEAD>
<BODY>

<a href="#null" onclick="openWin()">Open Pop</a>

</BODY>
</HTML>

VastCode
08-18-2005, 01:07 AM
Thanks, but I need a bit more help.

I understand what that does, and I understand each line. In the various arrays of the "urls" variable:



urls[0]="http://www.codingbrain.com"

etc...


How would I go about using javascript within. Here is an example:



urls[0]="window.location='http://site.com'"


I know that example is useless, but you get what I am asking. Any help?

Ultragames
08-18-2005, 08:23 AM
I suggest opening a new window with the script above, or one similar. The new window would then go to your page. On this page you would have a 100% frame, that has the site you want to show. Then you put the site changing script in your page.

Mr J
08-18-2005, 02:26 PM
Sorry but I am a bit confused, can you explain a bit more why you want it this way


urls[0]="window.location='http://site.com'"

Meanwhile, if the parent window is not going to be loaded all the time the popup is opened you can go this way.

In the parent page


<a href="#null" onclick="window.open('urlspop.htm')">Open Pop</a>

In urlspop.htm


<HTML>
<HEAD>
<TITLE>Document Title</TITLE>

<script type="text/javascript">
<!--

urls=new Array()
urls[0]="http://www.hrgiger.com"
urls[1]="http://www.joecartoon.com"
urls[2]="http://www.dhtmlnirvana.com"

time=5000
count=0

function nextUrl(){
document.getElementById("myiframe").src=urls[count]

count++

if(count==urls.length){
count=0
}

setTimeout("nextUrl()",time)
}


//-->
</script>
</HEAD>
<BODY onload="nextUrl()" style="margin:0;overflow:hidden">

<iframe src="" id="myiframe" width=100% height="100%"></iframe>


</BODY>
</HTML>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum