473,387 Members | 1,611 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,387 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 1726
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...

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.