Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Computing > NZ Computing > Using a variable in the src attribute of iframe

Reply
Thread Tools

Using a variable in the src attribute of iframe

 
 
Dany P. Wu
Guest
Posts: n/a
 
      11-17-2003
Okay, last time I asked a question about HTML I just about got my head
bitten off. Anyway, I'm game enough to try again in hope I'd get some useful
comments.

I've got a couple of pages which has a variable passed between them using
Javascript.

The opening page of the website has a bunch of links that look somewhat
like:

<a href="geninfo.html?sub_contact.html">

The page geninfo.html contains an inline frame called "frame" and has a
short script like this:

<!--
var temp=window.location.split("?");
var content=temp[1]
//-->

I am assuming after I clicked the link from the opening page the variable
"content" now contains "sub_contact.html". Am I correct?

How can I use this variable in my iframe tag?

I've tried this:

<iframe name="frame" height="409" width="580" border="0" frameborder="0"
src=content scrolling="auto">

but that's obviously wrong since it didn't work.

Can someone please tell me how I can achieve this? I have searched the web
but none of them really show how I can achieve this. They have a lot of
examples setting values of various controls on different frames of the same
page, but not inline frames. This has really got me confused. Some
assistance would be greatly appreciated.

Cheers,
Dany.


 
Reply With Quote
 
 
 
 
Jay
Guest
Posts: n/a
 
      11-17-2003
Dany P. Wu wrote:

> Okay, last time I asked a question about HTML I just about got my head
> bitten off. Anyway, I'm game enough to try again in hope I'd get some
> useful comments.
>
> I've got a couple of pages which has a variable passed between them using
> Javascript.
>
> The opening page of the website has a bunch of links that look somewhat
> like:
>
> <a href="geninfo.html?sub_contact.html">
>
> The page geninfo.html contains an inline frame called "frame" and has a
> short script like this:
>
> <!--
> var temp=window.location.split("?");
> var content=temp[1]
> //-->
>
> I am assuming after I clicked the link from the opening page the variable
> "content" now contains "sub_contact.html". Am I correct?
>
> How can I use this variable in my iframe tag?
>
> I've tried this:
>
> <iframe name="frame" height="409" width="580" border="0" frameborder="0"
> src=content scrolling="auto">
>
> but that's obviously wrong since it didn't work.
>
> Can someone please tell me how I can achieve this? I have searched the web
> but none of them really show how I can achieve this. They have a lot of
> examples setting values of various controls on different frames of the
> same page, but not inline frames. This has really got me confused. Some
> assistance would be greatly appreciated.


Your 'src=content' isn't going to be interpreted as javascript, is it?
How is the HTML interpreter to know what it is?

I'm not sure of the exact answer but something like src=javascript:content
or via a javascript function like src="javascriptpenit('content')" is
going to have a better chance of working.

 
Reply With Quote
 
 
 
 
rob
Guest
Posts: n/a
 
      11-17-2003

"Dany P. Wu" <> wrote in message
news:...
> Okay, last time I asked a question about HTML I just about got my head
> bitten off. Anyway, I'm game enough to try again in hope I'd get some

useful
> comments.
>
> I've got a couple of pages which has a variable passed between them using
> Javascript.
>
> The opening page of the website has a bunch of links that look somewhat
> like:
>
> <a href="geninfo.html?sub_contact.html">
>
> The page geninfo.html contains an inline frame called "frame" and has a
> short script like this:
>
> <!--
> var temp=window.location.split("?");
> var content=temp[1]
> //-->
>
> I am assuming after I clicked the link from the opening page the variable
> "content" now contains "sub_contact.html". Am I correct?
>
> How can I use this variable in my iframe tag?
>
> I've tried this:
>
> <iframe name="frame" height="409" width="580" border="0" frameborder="0"
> src=content scrolling="auto">
>
> but that's obviously wrong since it didn't work.
>
> Can someone please tell me how I can achieve this? I have searched the web
> but none of them really show how I can achieve this. They have a lot of
> examples setting values of various controls on different frames of the

same
> page, but not inline frames. This has really got me confused. Some
> assistance would be greatly appreciated.
>
> Cheers,
> Dany.
>
>


Hi Dany,

don't assume that I actually know what I'm talking about but....
I reckon you may need to use Document.write (javascript) to combine the HTML
and the javascript variable.
So you might have something like this:

<iframe name="frame" height="409" width="580" border="0" frameborder="0"
scrolling="auto"

<script language="JavaScript">
<!--
document.write "src=" & content & ">"
//-->
</script>

I expect I've got some syntax wrong etc. but you get the idea.

If you want to speak to some pretty knowledgeable people you could try the
pviiwebdev newsgroup on forums.projectseven.com
I have a wee lurk around there from time to time - they're a pretty friendly
bunch.
have fun
rgds
rob


 
Reply With Quote
 
rob
Guest
Posts: n/a
 
      11-17-2003
by the way, I'd shy away from using frame as a name - it maybe a reserved
word or some such.


 
Reply With Quote
 
Mainlander
Guest
Posts: n/a
 
      11-17-2003
In article <>,
says...
> Okay, last time I asked a question about HTML I just about got my head
> bitten off. Anyway, I'm game enough to try again in hope I'd get some useful
> comments.
>
> I've got a couple of pages which has a variable passed between them using
> Javascript.
>
> The opening page of the website has a bunch of links that look somewhat
> like:
>
> <a href="geninfo.html?sub_contact.html">
>
> The page geninfo.html contains an inline frame called "frame" and has a
> short script like this:
>
> <!--
> var temp=window.location.split("?");
> var content=temp[1]
> //-->
>
> I am assuming after I clicked the link from the opening page the variable
> "content" now contains "sub_contact.html". Am I correct?
>
> How can I use this variable in my iframe tag?
>
> I've tried this:
>
> <iframe name="frame" height="409" width="580" border="0" frameborder="0"
> src=content scrolling="auto">
>
> but that's obviously wrong since it didn't work.
>
> Can someone please tell me how I can achieve this? I have searched the web
> but none of them really show how I can achieve this. They have a lot of
> examples setting values of various controls on different frames of the same
> page, but not inline frames. This has really got me confused. Some
> assistance would be greatly appreciated.


Straight HTML contains nothing at all to do with variables. Your example
would need to be rewritten to use Javascript to output the frame name in
the place where you have shown the variable name.
 
Reply With Quote
 
Dany P. Wu
Guest
Posts: n/a
 
      11-18-2003
"rob" <> wrote in message
news:bpbamq$s4j$...
> Hi Dany,
>
> don't assume that I actually know what I'm talking about but....
> I reckon you may need to use Document.write (javascript) to combine the

HTML
> and the javascript variable.
> So you might have something like this:
>
> <iframe name="frame" height="409" width="580" border="0" frameborder="0"
> scrolling="auto"
>
> <script language="JavaScript">
> <!--
> document.write "src=" & content & ">"
> //-->
> </script>
>
> I expect I've got some syntax wrong etc. but you get the idea.


Thanks Rob, I figured it out when I got out of bed this morning and you're
right, your syntax is wrong but the general idea of parsing the variable
into the HTML tag is right on the spot!

> If you want to speak to some pretty knowledgeable people you could try the
> pviiwebdev newsgroup on forums.projectseven.com
> I have a wee lurk around there from time to time - they're a pretty

friendly
> bunch.
> have fun


Thanks for that too.

Cheers,
Dany.


 
Reply With Quote
 
Lawrence DčOliveiro
Guest
Posts: n/a
 
      11-18-2003
In article <>,
"Dany P. Wu" <> wrote:

>How can I use this variable in my iframe tag?


You need to use Dynamic HTML. That is to say, by making assignments to
appropriate objects within the document, you can selectively replace
content. Here's a quick-and-dirty working example I just threw together:

<HTML>
<HEAD><TITLE>IFRAME Test</TITLE>
<BODY>
<P>This text comes before.
<P><IFRAME NAME="testframe" SRC="http://www.microsoft.com/" WIDTH=400
HEIGHT=400>
<P>This text comes after.
<BUTTON ONCLICK="document.testframe.location =
'http://www.apple.com'">Click Me</BUTTON>
</BODY>
</HTML>

This initially loads up showing the Microsoft home page within the
iframe. Click the "Click Me" button, and this is changed to the Apple
home page.

Anyway, that should give you the idea.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Java Src to J2ME Src? macbrando@gmail.com Java 1 03-23-2007 01:29 PM
Iframe's src attribute Santel HTML 5 01-17-2007 11:04 AM
<txt src= ...> equivalent of <img src= ...> Steve Richter ASP .Net 3 02-09-2006 08:44 PM
src.jar (src.zip) missing on Mac OSX Java 1.4.1 installation? Greg Johnson Java 4 09-18-2003 07:21 AM
Problem: Setting MSIE iframe innerHTML change relative href/src to absolute href/src Soren Vejrum Javascript 4 07-05-2003 01:47 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57