473,830 Members | 2,140 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="JavaS cript" 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.Lengt h;
DocName = "documents/"+SearchStr.Sub string(7,NameLe n);
}
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.GetDocN ame()"></IFRAME>
Any help with this would greatly be appreciated!

Ralph

Sep 21 '05 #1
3 1747
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="JavaS cript" 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.Lengt h;
DocName = "documents/"+SearchStr.Sub string(7,NameLe n);
}
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.GetDocN ame()"></IFRAME>


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

or

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

--
Stephane Moriaux et son [moins] vieux Mac
Sep 21 '05 #2
webguru <ra**********@h otmail.com> wrote in message news:11******** *************@g 14g2000cwa.goog legroups.com...
NameLen = SearchStr.Lengt h;
should be SearchStr.lengt h;
DocName = "documents/"+SearchStr.Sub string(7,NameLe n);
'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.sear ch.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
4690
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. It works fine in IE, but not FireFox. I would like to implement these menus, but if I can't get this to work, I gotta look at something else. If anyone has some suggestions, I would appreciate it.
2
1389
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 ReportTransition.htm referenced simply contains this (nothing else): <img src="ReportTransition.gif" /> The following is the html that does not work in Netscape 7, any idea what's wrong with it or a way I could do this better?
2
2361
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. However, if I load the page in a Iframe the list is not sortable. The javascript gets stuck, see http://www.molca.com/kknotoke.html. I have searched the complete Internet, but I can not find a reference to this particular problem. What is the basic idea...
21
6163
by: javainfo | last post by:
How can i refresh IFRAME and load data through AJAX?
3
4497
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 includes background music with a javascript music player on the main page below an iframe that is used for all content and navigation of the site and so that the music doesn't reload each time a page is switched. There is another javascript to resize...
3
5401
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 the html page. But if I try to navigate to another pdf in the IFRAME then no caching occurs. Is the problem in the IFRAME reloading instead of just refreshing the pdf? <SCRIPT type="text/javascript"> var pageNo; var nav; var iframe; var...
1
7889
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 you know, the Google insertion. I’ve already cleaned up the page to not use frames anymore, using SSI,
5
13394
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 http://mghospedagem.com/images/controlpanel.jpg instead of http://mghospedagem.comhttp://mghospedagem.com/images/controlpanel.jpg As u see, there's the website URL before the image URL.
0
9793
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10777
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...
1
10526
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
9315
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...
1
7747
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4416
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
3960
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
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.