Opening URLs in a browser automatically
Posted: Thu Oct 13, 2005 4:08 pm
feyd | Please use
As you can see, I tried to use the variable from the PHP code which holds the value of the URL to be processed (the $processurl variable). It was from a tutorial I found on Google but it wasn't very clear so it may well be wrong! Also it's been a while since I used Javascript!
Anyway, I hope that someone can help or provide some pointers for this as I've been trying stuff out for about 4 hours now and my brain's gone numb!
- Gordon
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi,
I'm relatively new to PHP coding so please excuse me if this is a stupid question!
Well, I'm writing a piece of code that reads a list of URLs from a text file and then outputs them in a browser, one at a time at set intervals. Kind of like a slideshow but with websites instead of pictures.
I'm using a while loop to process the URLs, so everytime the loop runs a variable acts as a counter and gets a 1 added to it, so that the next URL in the array can be fetched the next time.
The program reads the URLs in the text list into an array just fine and the loop works too - I've just been getting it to output what it's doing to the screen at the moment, so that I can see it's working.
Well, this brings me on to the problem - I need to get the program to actually take the URLs in the array and fetch the actual website into the user's browser. I'm not too sure how to go about this.
What I want is for the user to see a webpage with two frames. the top will have the PHP code and the dialogue the code generates now (this is just stuff like "now showing URL 1, URL 2, etc.") so that the user can see what the program is doing as it runs. The bottom frame will actually show the websites in it. So say, for example, URL 1 in the array is http://www.yahoo.co.uk - the top frame will say "Now showing URL 1" and Yahoo will be showing the bottom frame, and so forth. As I said, I have the top frame working - it's just the bottom one that's the problem!
I've tried putting Javascript into the loop so that it would be executed everytime the loop ran, and would output the URL into the bottom frame but this doesn't seem to work - it just seems to be ignored and nothing happens - the top frame works but the bottom stays blank.
I've also wondered if it's possible to simply call the frame in HTML and somehow add the URL in as a variable - but not sure if this is possible?
So, I guess what I'm asking is: How do I get the PHP code to open a URL in the bottom frame and also is it possible to use a variable as the address for the URL to refer to - so say would you be able to have something like "HREF=$showthisurl" (I know that's not valid code but just as an illustration of what I'm jabbering on about)?
Also, is it possible to put Javascript code into a While loop in PHP code so it will execute everytime the loop is executed, and furthermore is it possible to take a variable from the PHP code and use it in that Javascript code? I've seen some examples while Googling but none of them are particularly clear on this.
Here's my While loop code as it is right now with my attempt at adding the Javascript in (which seems to do nothing!):Code: Select all
while ( $arraycount >= $processcount ) {
print("Now processing url number ");
print $processcount;
print(" </BR>");
print("<SCRIPT LANGUAGE = JAVASCRIPT>");
print("parent.main.location.href = (<? $processurl; ?>)");
print("</SCRIPT>");
$processcount=$processcount + 1;
}Anyway, I hope that someone can help or provide some pointers for this as I've been trying stuff out for about 4 hours now and my brain's gone numb!
- Gordon
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]