Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need to pass a value from one html page to another for javascript to 1

Status
Not open for further replies.

dcutter1

Programmer
Mar 9, 2000
7
US
I want to be able to pass a value from one html page to another html page using javascript in both pages. I'm using IFRAME to create an imbedded page and want to pass it a new value so that the contents will change. The target frame creates a
 
Well you didn't finished your post, but if I'm understanding you correctly, you can pass the value to the frame where the frame is a part of a parent document. It would look something like this: parent.theframesnamehere.document.variablesnamehere=newvaluehere <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
I guess I still need some help on this. The page I'm sending to has some code like this:<br>
<br>
&lt;SCRIPT LANGUAGE="Javascript" <br>
SRC="<br>
I want to be able to replace the websiteowner+js with a <br>
value passed from the parent page. I can't seem to figure out how to turn the SRC= into a variable that I can change.<br>
I should mention that I am a rank begginer as far as java is concered, so be gentle with the answer.
 
can you give a link to the website you're working with? Because I'm having a bit of trouble catching on... sorry :eek:( <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href= imotic ::</a><br>
 
I wouldn't send it as a parameter to the page itself as you are suggesting since that would require PHP, CGI, or Perl and I don't think you want to work with those, but it's completely up to you. I would rather send it to the frame itself, that is if you wish to avoid using those languages (actually, CGI isn't a language, just an application written in C or C++, compiled and used by the server). Not only that, if this isn't going to be on a computer you have direct access to (i.e. you will be using a service like Geocities or Crosswinds), you would need to make sure that they support PHP, CGI, or Perl. My suggestion is that you just send it to the frame itself. <p>REH<br><a href=mailto:hawkdogg@crosswinds.net>hawkdogg@crosswinds.net</a><br><a href= by Linux</a><br>Learn Linux and Leave out the Windows :)
 
I'm most likly leaving a little to much out of my question. I have an index page that has IFRAME's in it. One of them is a news html document that needs to have a value passed to it such that it will replace an internal value of the<br>
following code: <br>
&lt;SCRIPT LANGUAGE="Javascript" id="newspage" SRC="<br>
The frame is discriped so:<br>
<br>
&lt;iframe src="./news/linux.html" align="top" width="225" height="2300" id="news" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"&gt; &lt;/iframe&gt;<br>
<br>
Can I pass parent.news.document.newspage=newvaluehere where newvaluehere = "<br>
I haven't got this to work. I'm not sure if this is what you ment by variablesnamehere, which I think you were assuming I ment was a var in the document I was calling in the IFRAME. I hoped I've explained this a little better this time. <br>
<br>
 
What does the Javascript itself do? write HTML into the IFRAME?<br>
<br>
You can totally rewrite a part of an HTML page with document.write, which works on both browsers, but since your page is only supporting IE, you can take advantage of a nice feature of IE 4 and 5: InnerHTML. The InnerHTML object lets you dynamically change the contents of any HTML inside any tag. The documentation for this at the MSDN site is lacking, but if you read any of the latest big books on IE5 programming, you will find this.<br>
<br>
Basically:<br>
<br>
document.all.{whatever_html_object).InnerHTML={whatever_variable}<br>
<br>
will change actual HTML inside that tag. It works for IFRAME, among many others.<br>
<br>
Not sure if this helps you at the moment: I really need to know what the Javascript is supposed to accomplish to help more.<br>
<br>

 
I tried using a doucument.write for the javascript but it<br>
didn't work. I can't remember the error at this time<br>
though. It pains me some that Netscape doesn't support <br>
IFRAMES. I tried their ILAYER but the second and 3rd<br>
panel kept comeing up a mess so I gave up on it for now.<br>
Mozillia supports my site with their latest daily build<br>
so I'm going to inform Netscape users to try that <br>
browser instead. That's one of the things I'll work<br>
on later to see if I can get it cross-browser enabled.<br>
<br>
All this code is in index.html<br>
==============================<br>
this code changes iframes<br>
news panel.<br>
&lt;SCRIPT language=JavaScript&gt;<br>
&lt;!-- // hide<br>
function gotocluster(s)<br>
{ <br>
var d = s.options[s.selectedIndex].value<br>
document.all.news.src=d<br>
s.selectedIndex=0<br>
}<br>
// end hide --&gt;<br>
&lt;/SCRIPT&gt;<br>
<br>
<br>
form selection to change news item.<br>
<br>
&lt;FORM action=javascript:gotocluster(s);&gt;<br>
&lt;SELECT onchange=gotocluster(s)&gt;<br>
&lt;OPTION value=./news/3m.html&gt;3M&lt;/OPTION&gt;<br>
ect.....<br>
<br>
this is what the iframe that I am changing looks like.<br>
<br>
&lt;IFRAME id=news src=&quot;./news/linux.html&quot;&gt;<br>
&lt;/IFRAME&gt;<br>
<br>
end of index.html code<br>
===============================<br>
<br>
<br>
news.html code<br>
==============================<br>
this code is in body of the news html<br>
document. There's code above and<br>
below it to process the file this brings<br>
in.<br>
&lt;SCRIPT LANGUAGE=&quot;Javascript&quot; <br>
SRC=&quot;<A HREF=" TARGET="_new">&lt;/SCRIPT&gt;<br>
<br>
Right now I have one of these documents for each news item (248 pages) So what I'm looking for is a way to pass something from index.html to the news html such that I only need one of the documents instead of 248. I can see how<br>
I could use the innerHTML to change the javascript SRC=<br>
once I get something passed to the news html, but this <br>
is were my newness to javascript fails me. <br>
<br>
The address of page I'm working on is <A HREF=" TARGET="_new">I'm using it as kind of a training exercise to learn<br>
html and java. Three months ago I could hardly spell HTML, but I think I've come aways since. It's sitting behind <A HREF=" TARGET="_new"> on my computer at home at this time, also the site 24link has frames so you will have to download the page if you want to see more. I hope I've finally made clear my problem (other than my rank newness to all of this).
 
Hmmm...Your site is about Linux, but you're supporting Internet Explorer for Windows. I'm not sure about you...<br>

<br>

Anyway, you are right, you can't embed JavaScript in a JavaScript write function, it just doesn't work, unless you include <script> and </script>. It may seem redundant, but understand that you are writing it to the document, not that area. The document is the resulting page. Don't forget, Netscape is the only graphical, non-beta (i.e. stable), and free browser for Linux, so keep that in the back of you mind. When you send the function <i>gotocluster(s)</i>, be sure that <i>s</i> is the name of the form or <i>thisform</i>, or else the browser will complain that it's not defined. You may also not be calling the layers correctly. Be sure it's called as <i>document.<font color=red>layernamehere</font></i>. You can then manipulate almost any attribute you want from there.<br>

<br>

I will admit that Microsofts IFRAME tag is a very nice feature. If it could be combined with a LAYER's flexibility, it would be best.
 
When I started out making my site I was following the 4.0 standards which has IFRAME as the way to do in page frames. It wasn't until later that I realized the incompatability of the current version of netscape to the 4.0 standard. I've looked around about Netscape, which I do use, but now I've seen post saying that Netscape is going to abandon layers and comply with the 4.0 standard. That puts me in somewhat of a delema as I want something that really can suppport all the browsers that I can and still make my site work the way I want, I like getting my cake and eating it too! I've decided since IE5 and Mozillia already support my site that that is good enough for me for now. I know that Netscape 5.0 will also support IFRAME and it is comming out next month (I think). The main perpose of my site is to introduce non-Linux users to the system and educate them about it. As such most of them will be using IE5, at least at first. At the rate I'm building this site (it's taken me almost 3 months to just get somewhat done with the first page) I think most of this will be moot and all the new browsers will support IFRAME. <br>
<br>
I just can't say how tired I am of windoze 98E puking on me all the time, usally when I've got html pages open that I'm editing and losing all the changes I've made. I've even completly lost my system once and had to rebuild the entire system. That's when I got the linux feaver and now I have a dual disk system with Corel Linux on one drive and<br>
Wind-death 98 on the other. It's a sad fact that until we build up a suit of applications that can do most of the things that Wind-out-of-the-ass-deep-6 (hey can we swear a little on this site) can do that we will have to put up with this operating system. <br>
<br>
I'd like to thank all you guys that have been trying to help with this problem. Sometimes it seems that what should be simple in most langugues is very hard in others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top