473,835 Members | 1,740 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

iframe src variables

I'm having trouble figuring out the proper way to pass this variable
in with javascript alone. I'm not used to not being able to use jsp
and all the love that is in that.

Obviously I know little about javascript!

So you get the whole story, the user will begin on a page which has an
iframe in it that picks up a parameter
http://wildlifedisease.nbii.gov/ecor...theirpage.html

which contains an iframe that passes a parameter when the form is
submitted to ANOTHER page with an iframe which needs to pick up that
parameter.

So, for example, if you put in 11211 in the text box on the first
page, and submit it, it opens a new window and pushes over the zipcode
parameter value to that next page
http://wildlifedisease.nbii.gov/ecor...?zipcode=11211

what i need to do now, is get the iframe in bigpage.html to pick up
that zipcode parameter.

i'm using a substring function (here's the code for bigpage.html) to
get the zipcode value

<html>
<body>
<script type="text/javascript">
var zipcode2=window .location.searc h.substring(9);
alert(zipcode2) ;
</script>
<iframe frameborder="0" height="100%" width="100%"
src="http://wildlifedisease .nbii.gov/ecoregions/index.jsp?zipco de=
+zipcode2.value +"></iframe>
</body>
</html>

which works fine, but I can't figure out how to properly write the
src="" part.. i've tried every combination of apostrophes and plus
signs, argh!

help?

Thanks!!!!
Jun 27 '08 #1
2 6868
mkhines escribió:
<html>
<body>
<script type="text/javascript">
var zipcode2=window .location.searc h.substring(9);
alert(zipcode2) ;
</script>
<iframe frameborder="0" height="100%" width="100%"
src="http://wildlifedisease .nbii.gov/ecoregions/index.jsp?zipco de=
+zipcode2.value +"></iframe>
</body>
</html>
You can't just insert JavaScript code anywhere in your HTML. If you
write "zipcode2.value ", how can the browser know it's not HTML?

You probably want something like this, but please make sure you
understand why your code did not work and you'll prevent lots of headaches.

<script type="text/javascript"><!--
var zipcode2=window .location.searc h.substring(9);
// This is only one line, it was wrapped by my newsreader:
document.write( '<iframe frameborder="0" height="100%" width="100%"
src="http://wildlifedisease .nbii.gov/ecoregions/index.jsp?zipco de=' +
escape(zipcode2 .value) + '"><\/iframe>');
//--></script>

Code is not tested.

Be aware that your iframe won't event exist for non JS aware user agents.

--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://bits.demogracia.com
-- Mi web de humor al baño María: http://www.demogracia.com
--
Jun 27 '08 #2
On May 29, 4:32 am, "Álvaro G. Vicario"
<alvaroNOSPAMTH A...@demogracia .comwrote:
mkhines escribió:
<html>
<body>
<script type="text/javascript">
var zipcode2=window .location.searc h.substring(9);
alert(zipcode2) ;
</script>
<iframe frameborder="0" height="100%" width="100%"
src="http://wildlifedisease .nbii.gov/ecoregions/index.jsp?zipco de=
+zipcode2.value +"></iframe>
</body>
</html>

You can't just insert JavaScript code anywhere in your HTML. If you
write "zipcode2.value ", how can the browser know it's not HTML?

You probably want something like this, but please make sure you
understand why your code did not work and you'll prevent lots of headaches..

<script type="text/javascript"><!--
var zipcode2=window .location.searc h.substring(9);
// This is only one line, it was wrapped by my newsreader:
document.write( '<iframe frameborder="0" height="100%" width="100%"
src="http://wildlifedisease .nbii.gov/ecoregions/index.jsp?zipco de='+
escape(zipcode2 .value) + '"><\/iframe>');
//--></script>

Code is not tested.

Be aware that your iframe won't event exist for non JS aware user agents.

--
--http://alvaro.es- Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web:http://bits.demogracia.com
-- Mi web de humor al baño María:http://www.demogracia.com
--
Thanks, I eventually did this based on another recommendation. I do
see that as a problem, but if I need to pass variables to an iframe on
a different group's server, i'm not sure there is any other way for me
to do what i'm trying to do.. we need to host the application on a
server that can run tomcat/database etc. and they don't have that
ability.

(here is the code i went with in the end)
<html>
<script type="text/javascript">
function init() {
var zipcode2 = window.location .search.substri ng(9);
var url = "http://wildlifedisease .nbii.gov/ecoregions/
index.jsp?zipco de=" + zipcode2;
document.getEle mentById("myfra me").src = url;
}
</script>
<body onLoad="init()" >
<iframe id="myframe" frameborder="0" height="100%" width="100%"
src=""></iframe>
</body>
</html>

is there some other way to pass those variables to the iframe without
javascript?

thanks!

megan
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9311
by: Catherine Lynn Smith | last post by:
I want to know the recommended way to handle scripting of/with containers such as an iframe. I have a page with border-navigation bars on the top/bottom/left/right and I want to use an iframe to load content in the middle. I would like, if possible, to have the parent window resize itself to suit whatever is loaded into the iframe container, deriving the size needed from calculated values. Thus the calculation would have to over-ride...
0
1260
by: John Wood | last post by:
I have an ASP script in which I want to control the screen as two frames If I use a FRAMESET this works fine but the frame geometry is fixed the script uses POST and hidden fields to transfer the data from step to step, what I would like is to be able to change the sizes of the frames or even go from two frames to one and back to two as I go through the dialogue. So I thought to use IFRAMES instead of a frameset, but now I have two ASP...
26
45542
by: Dave Hammond | last post by:
In document "A.html" I have defined a function and within the document body have included an IFRAME element who's source is document "B.html". In document "B.html" I am trying to call the function defined in "A.html", but every attempt results in an "is not a function" error. I have tried to invoke the function using parent.document.funcname(), top.document.funcname(), and various other identifying methods, but all result in the above...
2
2458
by: bs9999 | last post by:
I'm using IFRAME to connect back to my ASP.NET page in order to fetch the FreeBox HTML Editor html contents and scripts (i do this apprach because the html editor is fairly heafty to send to the user when most dont use it on our site instead deferring to a user request before actually sending down the code via AJAX or in this case an IFRAME). append all script tags and relevant html elements into my main page's DOM, outside of the iframe....
5
2063
by: pbd22 | last post by:
hi. i have a hidden iframe for uploading files. when i check the httpfilecollection on the server, it is always zero - the files never make it to the server. i know all the javascript is working correctly on the client b/c i have followed the local variables using venkman. so, something is happening on the server.
4
19519
by: Jayyde | last post by:
Is there any way to capture a button click inside an iFrame and perform both an action on that page and one on the parent page? Basically I have a page atm that allows the user to add a record to a table and what I would like to have are save and cancel buttons (or maybe just a save button with a close image on the DHTML "window") on the page that, when save is clicked for instance, will save the record (code in that page) and close the...
0
1303
by: bnashenas1984 | last post by:
Hi I have a form which sends some variables. but i need to have an IFRAME inside this form which has its own variables. My question is if i can get this IFRAM's variables into my main page ( parent ) here is the first file 1.php <form action="1.php" method="post">
3
7799
by: kierandes | last post by:
Hey Guys, I am trying to make a iframe that changes depending on variables I call from a database. The database is working, variables are filling up, but I am having trouble with the echoing a iframe with the php variables within it. With some help from Markus I've made some progress but my attempts so far have been unsuccessful. echo "<iframe SRC=/"http://www.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=\"\" , $lat_mins ,...
0
10812
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10561
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10235
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9346
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7766
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3995
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.