468,719 Members | 1,787 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,719 developers. It's quick & easy.

Loading Javascript dynamically into a page.

I have a 3 frame window. When you type an address in the top it loads it in the middle. This works well but I need to dynamically load a small javascript function into the page that loads. I didn't know if it was possible to just throw it in there some how or if I have to copy the entire contents of the web site into an array which already holds the script....and if this was the case I am not even sure how to do it. If anyone can help that would be great.

Thanks in advance.
Rob



-- EDIT --

Ok, I decided to use IFrames instead of normal frames. So now I have 3 iFrames called Top, Middle, Bottom. I have a textbox in top that I want users to type an address in and it opens that page in middle....but I can't figure it out. I have tried many variations of...

window.frames['middle'].location.href=window.frames['title'].document.forms[field1].value;

What am I doing wrong?

Thank you again
Jul 11 '07 #1
4 1382
Bwa ha ha! I got it! Well, at least the opening of the web page into the iframe..

frames['middle'].location.href=frames['title'].document.getElementById('field1').value;

I am still needing to dynamically insert a script into this new page that loads though. I cant have it call the parent function because that page doesn't know about it because it is an outside page, such as google.com, msnbc.com, etc. I want to insert the javascript function at the top of the page that loads there...if its possible

HELP!

=)


--- EDIT ---

Would something like this work?

frames['middle'].location.href=frames['title'].document.getElementById('field1').value;
var e = '"onMouseDown=parent.getSelText()" oncontextmenu="return false;"';
frames['title'].document.getElementsByTagName("body")[0].appendChild(e);

or

var myElement = document.createElement('<BODY onMouseDown="getSelText()" oncontextmenu="return false;">');
frames['middle'].document.all.myBody.appendChild(myElement);
Jul 11 '07 #2
acoder
16,027 Expert Mod 8TB
If the page is from another domain, you won't be able to modify it (as far as I recall). Is it from the same domain?
Jul 12 '07 #3
Its not from the same domain....Grrrr...

Any ideas on what I can use to get this to work? .cgi, php, asp? I need to take a web page and insert 1 line of code into it. When they use the url box to change pages it then inserts the line of code into that page as well.
Jul 12 '07 #4
acoder
16,027 Expert Mod 8TB
What does that one line of code do?
Jul 14 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

By using this site, you agree to our Privacy Policy and Terms of Use.