Forum Moderators: open

Message Too Old, No Replies

Calling an iFrame from Javascript

Rather than having the iFrame code in HTML

         

script33

2:22 pm on Jul 11, 2007 (gmt 0)

10+ Year Member



i want summon a code from my server
4 example i have a fram code or others...
but i dont want insert that straight in my pages
i want summon that!
4 exam:
<script language="javascript" src="http://www.example.com/fram-code.js"></script>

i can insert my code in the adbrite-code.js?

this code:
<iframe src="http://www.example.com" width="300px" height="300px">
</iframe>

[edited by: DrDoc at 7:17 am (utc) on July 28, 2007]

script33

8:16 pm on Jul 11, 2007 (gmt 0)

10+ Year Member



i want this:

i have i frame code (HTML)
<iframe src="http://google.com" width="300px" height="300px">
</iframe>

but i want that into the js file!
i want iframe code with javascript!

U have it?

script33

8:17 pm on Jul 11, 2007 (gmt 0)

10+ Year Member



this is :?

if (!IFrameObj && document.createElement) {
// create the IFrame and assign a reference to the
// object to our global variable IFrameObj.
// this will only happen the first time
// callToServer() is called
try {
var tempIFrame=document.createElement('iframe');
tempIFrame.setAttribute('id','RSIFrame');
tempIFrame.style.border='0px';
tempIFrame.style.width='0px';
tempIFrame.style.height='0px';
IFrameObj = document.body.appendChild(tempIFrame);

if (document.frames) {
// this is for IE5 Mac, because it will only
// allow access to the document object
// of the IFrame if we access it through
// the document.frames array
IFrameObj = document.frames['RSIFrame'];
}
} catch(exception) {
// This is for IE5 PC, which does not allow dynamic creation
// and manipulation of an iframe object. Instead, we'll fake
// it up by creating our own objects.
iframeHTML='\<iframe id="RSIFrame" style="';
iframeHTML+='border:0px;';
iframeHTML+='width:0px;';
iframeHTML+='height:0px;';
iframeHTML+='"><\/iframe>';
document.body.innerHTML+=iframeHTML;
IFrameObj = new Object();
IFrameObj.document = new Object();
IFrameObj.document.location = new Object();
IFrameObj.document.location.iframe = document.getElementById('RSIFrame');
IFrameObj.document.location.replace = function(location) {
this.iframe.src = location;
}
}
}

script33

7:47 am on Jul 12, 2007 (gmt 0)

10+ Year Member



any body hav not ifram code into the java?

trillianjedi

8:10 am on Jul 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you not just have the JS file echo out the iFrame code?

TJ

script33

9:28 am on Jul 12, 2007 (gmt 0)

10+ Year Member



no

plz help me

cvele

10:24 am on Jul 12, 2007 (gmt 0)

10+ Year Member



heh dude? try to remain calm and tell us what do you exactly want to do.

script33

11:11 am on Jul 12, 2007 (gmt 0)

10+ Year Member



i want insert ifram codes in my pages
but i want any budy can not see that iuse ifram
4 example i insert code into the a js file an called it

4 exam i want use this sample:
<script src="http://www.example.com/fram.js" type="text/javascript"></script>

but it doesnt work

plz help me....

[edited by: DrDoc at 7:17 am (utc) on July 28, 2007]
[edit reason] Examplified URL [/edit]

trillianjedi

11:40 am on Jul 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm still not sure why you can't just echo out the iFrame code from the javascript. Can you explain why you're unable to do that? Then we may have a better idea of what you're trying to achieve.

TJ

script33

12:31 pm on Jul 12, 2007 (gmt 0)

10+ Year Member



how i can insert iframe code in to the js files and called it?
4 example:
http://www.example.com/fram.js

and called it with this script:
<script language="javascript" src="http://www.example.com/fram.js"></script>

how?
(my java dont work - plz help me and solv my js file)

[edited by: DrDoc at 7:15 am (utc) on July 28, 2007]
[edit reason] Examplified URLs [/edit]

trillianjedi

12:39 pm on Jul 12, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



how i can insert iframe code in to the js files and called it?

Just echo it out. In the fram_code.js file, something like:-

document.write('<iframe frameborder="0" scrolling="no" height="300" width="300" name="myFrame" src="http://www.google.com"></iframe>');

Then in the HTML page:-

<script language="javascript" src="http://www.example.com/fram-code.js"></script>

If you can explain why you're unable to do that, it might help us understand exactly what you're trying to achieve.

script33

2:00 pm on Jul 12, 2007 (gmt 0)

10+ Year Member



tank U vety much dear trillianjedi
U solved my problem
tank U very very very much!

cvele

2:31 pm on Jul 12, 2007 (gmt 0)

10+ Year Member



well.. this has been very painfull

shelter

3:00 am on Jul 28, 2007 (gmt 0)

10+ Year Member



But very funny to read