View Full Version : Reading from frame

06-10-2007, 06:29 PM
Hi all,

I'm looking for someone who can help me creating a piece of code. The code should read either the content of a frame, which contains an external website, or the URL. Then it should run a loop, to check if the URL in the frame changes, and when it does, then run a function.

I have tried to make this in javascript, but i found out that javascript dosn't allow to read the URL from windows or frames which contain content from another server.
I have seen this been used on a couple of sites, but none of them are willing to help me out, but just if it can help you guys, here they are;

http://www.lotsmorefree.com <- Probably the best example

I hope you can help me, thanks!

06-10-2007, 07:51 PM
Hello there

I suggest you put your url thingy into a div, javascript allows you to get pretty much anything from those with a commend like

var varName = document.getElementById("DivName").innerHTML;

Then you could use javascript to deal with the variable content


06-10-2007, 11:47 PM
PHP can't do that, since PHP is a server side language. When a PHP file is requested from the server, the server runs through the PHP code, executes it, and then sends the output to the client. Once the output is sent, PHP is out of the picture until the next request to the server.


06-11-2007, 01:44 PM
Okay.. But does anyone have a suggestion to how this problem can be solved?

06-14-2007, 04:24 PM
Hello again!

First of, not sure what you mean by a frame containning an external website, unless you mean an iframe.

Still, I am not clear on what you want to achieve. You want to run a javascript function or a php function on content change?

to read the source url of an iframe you could try this

var url = document.getElementById("iFrameID").src;

then use javascript to loop and check if it changed every few seconds or minutes or hours, just a thought.