Forum Moderators: open

Message Too Old, No Replies

url substitution & iFrame

correct DOM syntax

         

tranmkp

8:54 pm on Nov 10, 2008 (gmt 0)

10+ Year Member



we use a url substitution for disaster recovery in case some of our servers are down. Our old site used frames, I wrote a litle gimmick urlSub.js, that references the secondary server:
---------------------------------------------------------------
var url_base = "example.com";
function urlSubstitution(url_in)
{
parent.frames['rightPane'].location.href = "http://"+ url_base + "/" + url_in;
}
----------------------------------------------------------------

everything has worked fine - Now the company wants to change the site - I am using a big iFrame now to display content. However - the urlSub links I had before will not work and I just know it is my lack of DOM knowledge. He is what I am using for the iFrame version:
----------------------------------------------------------------
var url_base = "example.com";
function urlSubstitution(url_in)
{
document.getElementById['portalFrame'].src = "http://"+ url_base + "/" + url_in;
}
------------------------------------------------------------------

and for reference, here is how I am calling the urlSub.js in my line: (using the Milonic drop down menus)

aI("text=Title Page;url=javascript:urlSubstitution('transco/sheet.asp?stype=0');target=portalFrame");

thanks all in advance - this has been a killer.

[edited by: eelixduppy at 6:06 am (utc) on Nov. 12, 2008]
[edit reason] exemplified [/edit]

astupidname

2:36 am on Nov 11, 2008 (gmt 0)

10+ Year Member



document.getElementById['portalFrame'].src

You can not use square brackets [] with document.getElementById as they denote an item in a collection or array in javascript. It may have worked ok before with parent.frames because frames are a dom collection of items that are frames. Use parens () with getElementById instead and see if that helps:
document.getElementById('portalFrame').src

astupidname

2:37 am on Nov 11, 2008 (gmt 0)

10+ Year Member



And by the way, welcome to webmasterworld!

tranmkp

7:23 pm on Nov 11, 2008 (gmt 0)

10+ Year Member



Thanks a lot stupidname!

Unfortunatly, nope - error - object expected...can find something...

astupidname

11:23 pm on Nov 11, 2008 (gmt 0)

10+ Year Member



parent.frames['rightPane'].location.href =

I may have missed that, the "parent" thing. Are you actually running the function from the page that's inside the frame (iframe)? If you are trying to access the parent document you could do: parent.document.getElementById('portalFrame').src = blahblahblah;
or if just changing the same iframes page (from itself): window.location = blahblahblah;

and for reference, here is how I am calling the urlSub.js in my line: (using the Milonic drop down menus)

aI("text=Title Page;url=javascript:urlSubstitution('transco/sheet.asp?stype=0');target=portalFrame");

I confess I am a bit confused and don't know what is going on there for sure.