Simple Javasricpt Help

Dell / Insperion
January 18, 2009 at 21:28:22
Specs: Windows XP, Intel 1.4ghz; 504mb
I working on my website and i have a iFrame showing another page...

I need to change the javascript variables of the iFrame page...

The catch is i dont have write access to the iFrame page only the page containing the iFrame...

Any way to make this possible will be GREATLY appriciated...


See More: Simple Javasricpt Help

Report •

January 19, 2009 at 10:42:16
You might try something as below. You can usually setup some event elsewhere to trigger swapping the src... it doesn't have to be a click on the iframe. You'd also probably want to set the initial source of the frame.
<script language="javascript">

function change(src) {

   document.getElementById("ifrm").src = src;

<iframe id="ifrm" src="#" onclick="change('some_url');"></iframe>


[edit]Oops; I misread the post. Does the other page parse a query string? I'm not sure otherwise; I apologize

Report •

January 22, 2009 at 14:13:13
ugh i dont think so here but i'll try to explain it again...

My page (page1) contains a iframe to (page2). I cannot change the javascript variables of page2 because it's write-protected. But i can write to page1. The variables i need to change of page2 from page1 are [var count = 10 to var count = 12] and [var chase = true to var chase = false]

if theres anyway to do this please help

Report •

January 23, 2009 at 16:41:41
If doc2 (its url) doesn't belong to the same domain as doc1, then from what I've read, you'll get an access denied error when trying to read any of the properties within doc2. That's to prevent spreading malicious code across domains.

If both docs reside in the same domain, then you can reference its object with something like:

try {
var ifrm = document.getElementById("id").contentDocument;
for(i=0; i < ifrm.childNodes.length; i++) {

catch(e) { alert(e); }

Check the nodes against the list here to see what is accessible.

Hope that helps.

Report •

Related Solutions

Ask Question