473,747 Members | 3,014 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 6861
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
9304
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
1256
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
45520
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
2456
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
2057
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
19515
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
1301
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
7796
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
9522
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...
0
9354
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9307
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
8233
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...
0
4588
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4860
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3296
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
2771
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2203
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.