473,289 Members | 1,929 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,289 software developers and data experts.

Trouble with IFRAME & Javascript

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 I would do
this. My URL should always look like this:

http://www.xxx.com/newsite/subpage.h...=filename.html

The javascript I came up with looks like this, because I will only have
one parameter and I know that with the ? and the = that the length of
the param name will always be 6.:

<SCRIPT language="JavaScript" type="text/javascript">

function GetDocName() {
var
SearchStr, // Search String
DocName, // Name of Document to Use
NameLen; // Length of Document Name

SearchStr = location.search;
NameLen = SearchStr.Length;
DocName = "documents/"+SearchStr.Substring(7,NameLen);
}
return DocName;

</SCRIPT>
What I don't know is how to get the results of the function into my
Iframe. This is what I have tried, with no luck:
<IFRAME height="600" width="780" scrolling="auto"
src="javascript:parent.GetDocName()"></IFRAME>
Any help with this would greatly be appreciated!

Ralph

Sep 21 '05 #1
3 1721
ASM
webguru wrote:
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 I would do
this. My URL should always look like this:

http://www.xxx.com/newsite/subpage.h...=filename.html

The javascript I came up with looks like this, because I will only have
one parameter and I know that with the ? and the = that the length of
the param name will always be 6.:

<SCRIPT language="JavaScript" type="text/javascript">

function GetDocName() {
var
SearchStr, // Search String
DocName, // Name of Document to Use
NameLen; // Length of Document Name

SearchStr = location.search;
NameLen = SearchStr.Length;
DocName = "documents/"+SearchStr.Substring(7,NameLen);
}
return DocName;

</SCRIPT>
What I don't know is how to get the results of the function into my
Iframe. This is what I have tried, with no luck:
<IFRAME height="600" width="780" scrolling="auto"
src="javascript:parent.GetDocName()"></IFRAME>


document.write('<IFRAME height="600" width="780" scrolling="auto" '+
'src="'+GetDocName()+'"><\/IFRAME>');

or

<body onload="parent.myIframe.location = GetDocName();">

--
Stephane Moriaux et son [moins] vieux Mac
Sep 21 '05 #2
webguru <ra**********@hotmail.com> wrote in message news:11*********************@g14g2000cwa.googlegro ups.com...
NameLen = SearchStr.Length;
should be SearchStr.length;
DocName = "documents/"+SearchStr.Substring(7,NameLen);
'Substring' should be 'substring' and the offset should be 6.

There's little point in assigning variables that are only to be referenced once,
so you could reduce the function to:

function GetDocName()
{
return "documents/"+location.search.substring(6, location.search.length);
}

or to make it independent of the length of the parameter:

function GetDocName()
{
var ls = location.search;

return "documents/"+ls.substring(ls.lastIndexOf('=')+1, ls.length);
}
What I don't know is how to get the results of the function into my
Iframe. This is what I have tried, with no luck:


You've been shown that so I won't repeat it.

--
Sep 21 '05 #3
Thank you both for your input. It works exactly like I wanted it to
now! I really appreciate it.

Sep 21 '05 #4

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

Similar topics

1
by: Martial Spirit | last post by:
Hello- I was amazed at the suckerfish drop-downs from AListApart.com. They work great except for one thing, if I position the drop-downs over an iframe element, on mouseover the menus disappear....
2
by: Brett Robichaud | last post by:
I'm using the HTML below as a transition page. It is shown while a page that takes a long time to load is processed (report.asp). It works just fine under IE6 but not Netscape 7. The...
2
by: arjenmeijer | last post by:
I am using the Drag & Drop Sortable Lists with javaScript and CSS from http://tool-man.org/examples/sorting.html. It works beautifully in a single page, see http://www.molca.com/kkoke.html. ...
21
by: javainfo | last post by:
How can i refresh IFRAME and load data through AJAX?
3
by: PCgeek | last post by:
sorry moved this over to javascript forum, didn't mean to post 2x! Hi guys, I'm trying to put the finishing touches on my website and could really use some help on this particular issue. My page...
3
polymorphic
by: polymorphic | last post by:
I have succeeded in embedding PDF files in a dynamic iframe. The problem is that I need the PDF to cache. If the PDF remains the same from page load to page load then the pdf is somehow cached with...
1
by: Hendrik Maryns | last post by:
Hi, I’ve read Jukka’s page about iframes and generally noted the advice not to use it, so I am looking for a proper way to handle this: http://www.weltladen-tuebingen.de/index_kontakt.html...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.