473,386 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Converting javascript into iframe

Hey, I need to convert this javascript code into iframe. The javascript goes into a server and brings out an ad banner. The X's is the server IP.

<script language="javascript" type="text/javascript" src="http://XXX.XXX.XXX.XXX/blahblah/0000/blahblahblah.php"></script>

What I need to do is convert that line of code into an iframe format so that it does the same job of going into the server and pulling out the banner. Right now if I just add on the iframe tags, all it does it return the server info.

<iframe src="http://XXX.XXX.XXX.XXX/blahblah/0000/blahblahblah.php"></iframe>

What I need is for the banner ad itself to be returned, not the server info. I'm not knowledgeable with converting from javascript to iframe, can anyone give me some help?

EDIT: Something else I realized is that if I just put in <iframe></iframe>, it still returns server info even though I never specified a target URL src.
Jun 19 '07 #1
9 16745
acoder
16,027 Expert Mod 8TB
Welcome to TSDN!

I assume blahblah.php returns a Javascript file. Try putting it in a browser to see the output.
Jun 20 '07 #2
I placed the url into my browser and it returned all of this:

Expand|Select|Wrap|Line Numbers
  1. var js='http://XXX.XXX.XXX.XXX/bannercode/5251/04FF9A29A4ED390C0A260146E8E2080E.php';...
snipped code because it was messing up formatting - moderator
Jun 20 '07 #3
It's weird because this code works:

<script language="javascript" type="text/javascript" src="http://XXX.XXX.XXX.XXX/bannercode/5251/04FF9A29A4ED390C0A260146E8E2080E.php"></script>

and it connects to the server, pulls out the banner ad and displays it. But when I try switching it to iframe, it doesn't work:

<iframe src="http://XXX.XXX.XXX.XXX/bannercode/5251/04FF9A29A4ED390C0A260146E8E2080E.php"></iframe>
Jun 20 '07 #4
acoder
16,027 Expert Mod 8TB
The reason why the first line works and the second one doesn't is that the output is Javascript. What you need to do is create another file with the first line then use that file in the iframe.
Jun 20 '07 #5
Oh great! That works! Thanks a bunch!

Now I just want to ask is that I have 8 different ad servers. The site I am making with the iframes basically dives into each server and returns a banner ad from each server into a table.

adservertest.html (example site) is where I will be having 8 iframe lines each pulling a banner ad out from each of the 8 servers. Will I have to make an individual file to hold each of the javascript lines?
In other words, do I have to do this?

adserver1.html
adserver2.html
adserver3.html
adserver4.html
adserver5.html
adserver6.html
adserver7.html
adserver8.html
Each of the above contains the respective javascript line for that specific server.

Then I have the adservertest.html which contains 8 <iframe></iframe> lines for each of the 8 files. Is there anyway to do it so that I can make just one file containing the javascript lines for each server (instead of 8 seperate files) from which the adservertest.html can pull it out from?
Jun 20 '07 #6
acoder
16,027 Expert Mod 8TB
You could use the URL search property (link). So the file could be adserver.html?num=1, and you could change the num value for the rest. In the actual file, you'd have to parse the search property (described in the link). If it equals 1, then write out the script tag for the first ad server, if 2, then for the 2nd server and so on.
Jun 21 '07 #7
Would it be possible for you to give me a very basic example of code so I can see how I would utilize the code to achieve the effect you mentioned with the URL arguments?
Jun 21 '07 #8
acoder
16,027 Expert Mod 8TB
You could have something as simple as ?1 at the end of the URL.

Then in your file, you could have the following code:
Expand|Select|Wrap|Line Numbers
  1. var num = location.search.substring(1);
  2. switch (num) {
  3.  case 1: document.write("<script src='...'><\/script>"); break;
  4.  case 2: ...
  5. }
Jun 22 '07 #9
Please help me in converting this to iframe
This is also a banner ad it works in blog but i want iframe

<script type="text/javascript" language="javascript">
var aax_size='300x250';
var aax_pubname = 'aoebtech-21';
var aax_src='302';
</script>
<script type="text/javascript" language="javascript" src="http://c.amazon-adsystem.com/aax2/assoc.js"></script>
Oct 5 '16 #10

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

Similar topics

7
by: Lorenzo Vaina | last post by:
Can i get the content of an URL and put it in a variable using javascript? I want js execute different operations varying a file that is on internet. Thanks, regards.
2
by: Robert Oschler | last post by:
I have an IFrame whose document is created completely by Javascript code at runtime. The document in the IFrame accesses Javascript functions in the top level document. This works fine most of...
3
by: webguru | last post by:
I am trying to be able to pass a parameter in my URL to a subpage that will load the file specified in the paramater into an IFRAME. I have hardly used Javascript, and am trying to figure out how...
5
by: Tudor Tihan | last post by:
Hi, This is my first post here, so please be kind. I have tryed to make a javascript html page loader by using an invisible <IFrame> and some javascript variable text passing between...
8
by: chrisdude911 | last post by:
how do i add video into a javascript web page with my own custom buttons?
18
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. ...
16
by: Phlip | last post by:
Javascripters: I have a page with an iframe inside. Let's say the iframe looks like this: <script src="/javascripts/prototype.js" type="text/javascript" /> .... <iframe id='grinder'...
15
by: Phlip | last post by:
Javascripters: I have an outer page and an inner iframe. The outer page calculates some javascript, and wants the inner frame to run it. The inner frame should hit a page on the same (private)...
5
by: brad | last post by:
I'll post my code below. My goal is to grab the selected text in an iFrame from javascript (really any way possible). When I highlight text in the iFrame and click the link outside of the iFrame, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.