473,748 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

dynamic iframes...

I need to replace iframes acc. to what option user chooses in a sel
obj.. but figured have to load a blank iframe when pg loads so I can
replace it.. (iframe gets put in a pre-existing div..) this is
approach.. I'm having some problems and would appreciate some help..
thank you very much...

var selItem;
var ifrCurr;
var div = document.getEle mentById("divPr icing");
// this var not being read inside functions..
// (even if I take out 'var' from declaration..)

function currIF() { // to load a blank iframe..
ifrCurr = document.create Element("iframe ");
ifrCurr.src = 'iframes/blank.html';
//div.appendChild (ifrCurr); // ****** var not being read...

document.getEle mentById("divPr icing").appendC hild(ifrCurr);
// errror on this line
// is null or not an obj... (??)
// no problem w/this line in below function..
}
window.onload=c urrIF();
function pricing() { // load iframes dynamically..
selItem = document.getEle mentById("produ ct").value;
var ifr = document.create Element("iframe ");
ifr.src = 'iframes/' + selItem + '.html';

document.getEle mentById("divPr icing").appendC hild(ifr);
// works fine here....

// div.appendChild (ifr); // ******* var not being read...

// document.getEle mentById("divPr icing").replace Child(ifr,ifrCu rr);
// can't use this line yet b/c problems w/function above....
}

thank you very much........ Frances

Sep 22 '05 #1
5 2232
Frances wrote:
I need to replace iframes acc. to what option user chooses in a sel
obj.. but figured have to load a blank iframe when pg loads so I can
replace it.. (iframe gets put in a pre-existing div..) this is
approach.. I'm having some problems and would appreciate some help..
thank you very much...

var selItem;
var ifrCurr;
var div = document.getEle mentById("divPr icing");
// this var not being read inside functions..
// (even if I take out 'var' from declaration..)

function currIF() { // to load a blank iframe..
ifrCurr = document.create Element("iframe ");
ifrCurr.src = 'iframes/blank.html';
//div.appendChild (ifrCurr); // ****** var not being read...

document.getEle mentById("divPr icing").appendC hild(ifrCurr);
// errror on this line
// is null or not an obj... (??)
// no problem w/this line in below function..
}
window.onload=c urrIF();
function pricing() { // load iframes dynamically..
selItem = document.getEle mentById("produ ct").value;
var ifr = document.create Element("iframe ");
ifr.src = 'iframes/' + selItem + '.html';

document.getEle mentById("divPr icing").appendC hild(ifr);
// works fine here....

// div.appendChild (ifr); // ******* var not being read...

// document.getEle mentById("divPr icing").replace Child(ifr,ifrCu rr);
// can't use this line yet b/c problems w/function above....
}

thank you very much........ Frances

this will not work, as users could change iframe even after they have
already chosen one.. I need to detect what iframe is loaded (i.e., what
FILE is loaded in iframe..) in order to replace it.. again thank you
very much...
Sep 22 '05 #2

Frances wrote:
I need to replace iframes acc. to what option user chooses in a sel
obj.. but figured have to load a blank iframe when pg loads so I can
replace it.. (iframe gets put in a pre-existing div..) this is
approach.. I'm having some problems and would appreciate some help..
thank you very much...

var selItem;
Do you still need selItem to be a global variable? It seems you're
only using it in your pricing() function.
var ifrCurr;
var ifrCurr = null;
var div = document.getEle mentById("divPr icing");
// this var not being read inside functions..
// (even if I take out 'var' from declaration..)

function currIF() { // to load a blank iframe..
ifrCurr = document.create Element("iframe ");
ifrCurr.src = 'iframes/blank.html';
//div.appendChild (ifrCurr); // ****** var not being read...

document.getEle mentById("divPr icing").appendC hild(ifrCurr);
// errror on this line
// is null or not an obj... (??)
// no problem w/this line in below function..
}
window.onload=c urrIF();
I believe you don't need to load a blank iframe. So you can remove
that line and the above function.


function pricing() { // load iframes dynamically..
selItem = document.getEle mentById("produ ct").value;
var ifr = document.create Element("iframe ");
ifr.src = 'iframes/' + selItem + '.html';

document.getEle mentById("divPr icing").appendC hild(ifr);
// works fine here....

// div.appendChild (ifr); // ******* var not being read...

// document.getEle mentById("divPr icing").replace Child(ifr,ifrCu rr);
// can't use this line yet b/c problems w/function above....
}

thank you very much........ Frances


You should code defensively. Ensure that you actually have an object.

function replaceIFrame()
{
if(div)
{
var selItem = document.getEle mentById("produ ct").value;
var newifr = document.create Element("iframe ");
newifr.src = 'iframes/' + selItem + '.html';

if(ifrCurr == null)
{
ifrCurr = div.appendChild (newifr);
}
else
{
div.replaceChil d(newifr, ifrCurr);
ifrCurr = newifr;
}
}
}

Sep 22 '05 #3
web.dev wrote:
Frances wrote:
I need to replace iframes acc. to what option user chooses in a sel
obj.. but figured have to load a blank iframe when pg loads so I can
replace it.. (iframe gets put in a pre-existing div..) this is
approach.. I'm having some problems and would appreciate some help..
thank you very much...

var selItem;

Do you still need selItem to be a global variable? It seems you're
only using it in your pricing() function.

var ifrCurr;

var ifrCurr = null;

var div = document.getEle mentById("divPr icing");
// this var not being read inside functions..
// (even if I take out 'var' from declaration..)

function currIF() { // to load a blank iframe..
ifrCurr = document.create Element("iframe ");
ifrCurr.src = 'iframes/blank.html';
//div.appendChild (ifrCurr); // ****** var not being read...

document.getE lementById("div Pricing").appen dChild(ifrCurr) ;
// errror on this line
// is null or not an obj... (??)
// no problem w/this line in below function..
}
window.onload=c urrIF();

I believe you don't need to load a blank iframe. So you can remove
that line and the above function.


function pricing() { // load iframes dynamically..
selItem = document.getEle mentById("produ ct").value;
var ifr = document.create Element("iframe ");
ifr.src = 'iframes/' + selItem + '.html';

document.getEle mentById("divPr icing").appendC hild(ifr);
// works fine here....

// div.appendChild (ifr); // ******* var not being read...

// document.getEle mentById("divPr icing").replace Child(ifr,ifrCu rr);
// can't use this line yet b/c problems w/function above....
}

thank you very much........ Frances

You should code defensively. Ensure that you actually have an object.

function replaceIFrame()
{
if(div)
{
var selItem = document.getEle mentById("produ ct").value;
var newifr = document.create Element("iframe ");
newifr.src = 'iframes/' + selItem + '.html';

if(ifrCurr == null)
{
ifrCurr = div.appendChild (newifr);
}
else
{
div.replaceChil d(newifr, ifrCurr);
ifrCurr = newifr;
}
}
}


thank you VERY MUCH, web.dev......:)

following yr post this is what I have now..

function pricing() {
//if (div) {
var div = document.getEle mentById("divPr icing");
var selItem = document.getEle mentById("produ ct").value;
var ifrCurr = null;
var ifrNew = document.create Element("iframe ");
ifrNew.src = 'iframes/' + selItem + '.html';

if (ifrCurr == null) {
ifrCurr = div.appendChild (ifrNew);
} else {
div.replaceChil d(ifrNew,ifrCur r);
ifrCurr = ifrNew;
}
// }
}

but it still puts new iframe NEXT TO current one, not on top...

(had to take out if(div) line, script did not work at all (did not load
iframe at all) if I left it in... (??) have TONS of divs on this page,
so probably don't need this.. (it detects whether or not there are any
divs on page, right?)

again many thanks.... Frances
Sep 22 '05 #4

Frances wrote:
web.dev wrote:
Frances wrote:
I need to replace iframes acc. to what option user chooses in a sel
obj.. but figured have to load a blank iframe when pg loads so I can
replace it.. (iframe gets put in a pre-existing div..) this is
approach.. I'm having some problems and would appreciate some help..
thank you very much...

var selItem;

Do you still need selItem to be a global variable? It seems you're
only using it in your pricing() function.

var ifrCurr;

var ifrCurr = null;

var div = document.getEle mentById("divPr icing");
// this var not being read inside functions..
// (even if I take out 'var' from declaration..)

function currIF() { // to load a blank iframe..
ifrCurr = document.create Element("iframe ");
ifrCurr.src = 'iframes/blank.html';
//div.appendChild (ifrCurr); // ****** var not being read...

document.getE lementById("div Pricing").appen dChild(ifrCurr) ;
// errror on this line
// is null or not an obj... (??)
// no problem w/this line in below function..
}
window.onload=c urrIF();

I believe you don't need to load a blank iframe. So you can remove
that line and the above function.


function pricing() { // load iframes dynamically..
selItem = document.getEle mentById("produ ct").value;
var ifr = document.create Element("iframe ");
ifr.src = 'iframes/' + selItem + '.html';

document.getEle mentById("divPr icing").appendC hild(ifr);
// works fine here....

// div.appendChild (ifr); // ******* var not being read...

// document.getEle mentById("divPr icing").replace Child(ifr,ifrCu rr);
// can't use this line yet b/c problems w/function above....
}

thank you very much........ Frances

You should code defensively. Ensure that you actually have an object.

function replaceIFrame()
{
if(div)
{
var selItem = document.getEle mentById("produ ct").value;
var newifr = document.create Element("iframe ");
newifr.src = 'iframes/' + selItem + '.html';

if(ifrCurr == null)
{
ifrCurr = div.appendChild (newifr);
}
else
{
div.replaceChil d(newifr, ifrCurr);
ifrCurr = newifr;
}
}
}


thank you VERY MUCH, web.dev......:)

following yr post this is what I have now..


Don't forget to include:

var div = document.getEle mentById("divPr icing");
function pricing() {
//if (div) {
var div = document.getEle mentById("divPr icing");
var selItem = document.getEle mentById("produ ct").value;
var ifrCurr = null;
var ifrNew = document.create Element("iframe ");
ifrNew.src = 'iframes/' + selItem + '.html';

if (ifrCurr == null) {
ifrCurr = div.appendChild (ifrNew);
} else {
div.replaceChil d(ifrNew,ifrCur r);
ifrCurr = ifrNew;
}
// }
}

but it still puts new iframe NEXT TO current one, not on top...

(had to take out if(div) line, script did not work at all (did not load
iframe at all) if I left it in... (??) have TONS of divs on this page,
so probably don't need this.. (it detects whether or not there are any
divs on page, right?)

again many thanks.... Frances


The if(div) statement is there to check if an object exists.

Sep 22 '05 #5

Concider this :
var Banana = document.getEle mentById("Orang e");
/*
This has created var var called Banana.
And stored to it a reference to an element with the id="Orange"
*/

if( Banana )
{
/*
If you reach this point there's an element on the page
with an id="Orange";
*/
}
else
{
/*
If you reach here there's no element on in the DOM
with the id="Orange";
*/
}
OK so that's why webdev was used this

function replaceIFrame()
{
var div = document.getEle mentById("divPr icing");
if(div)
{ ...
http://km0ti0n.blunted.co.uk/

Sep 22 '05 #6

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

Similar topics

10
3934
by: maxim vexler | last post by:
I'm reading a lot of talks lately about the term iFrame and with your permission would like to ask a few question about that : - what is iFrame, i mean what is it good for ? - does all the popular browsers support it (mostly mozilla & the much hated IE, google says the do but nothing is better that experienced answer) - iFrames replaces the old frames once used in html to show a number of pages in a single windows, right ? - what are...
0
2099
by: Dan Popa | last post by:
Check out the following 2 links: http://www.batisdev.com/admin/test_1images.asp http://www.batisdev.com/admin/test_2images.asp First page contain 4 IFRAMES and 1 IMG tags. Second page contain 4 IFRAMES and 2 IMGs tags. The problem is that the second IFRAME from the second page generates fires a new session.
25
3499
by: jullag | last post by:
Hi, does anyone know of any javascript method that does the same job as document.write(), but not necessarily at the end of the document? For instance, insert some text inside an element that has a specific ID tag? thanks a lot JL
2
2095
by: Guadala Harry | last post by:
1. Are IFrames supported only in uplevel versions of IE? If not IE exclusively, what browsers support IFrames? 2. Are IFrames going to be supported in the future - as far as anyone knows - or have they been deprecated and will no longer be supported in the future? Please note that I'm *not* asking for opinions on the merits of using IFrames or IFrames vs regular framesets or any other such...
4
1769
by: Pete | last post by:
Hello- I am have a real trying time finding information on this subject. I would like to create a web page that utilizes framesets (top & bottom) and a navigation control I created from a datalist that gets data from a sql datasource (sort of like a tabstrip). I'm getting pretty comforatable on the asp.net side of things, but I'm lacking in the javascript department. I understand that I need to add javascript to make the frames work...
11
6008
by: f.ruecker | last post by:
Hey Guys, I've done my research for a script that dynamically adjusts the height of the Iframe, but none of the scripts have the features, which I all need. Maybe one of you can help me: 1. The site contained in the Iframe is no on the same Domain nor Server as the main page 2. I can't put any code in the Iframe (YES, I do have permission to include the Iframe ;-)
9
2985
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I got the core of the javascript from here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm I noticed in the demo that sometimes the content takes a long
2
1581
CroCrew
by: CroCrew | last post by:
Hello everyone, I am building a page that has two iframes (xFrame1, and xFrame2) in it. Both the pages in the frames are the same and have like JavaScript function names within them. I want to call a function on the parent page that would call the like named function within the selected iframe by passing in a value in the function on the parent page. Here is my code on the parent page:
33
3009
by: Manikrag | last post by:
Hi Team, I have to adjust two pages which are provided by 2 diff. services based on some query string, as of now I am using iframes but could not set the height dynamically. Both the child pages can came up with any height. and iframes are useless in this case as I have to set some height or else it will take the defualt value for height property. I tried to set it thru java script and css but got the "access denied error" as java...
0
8995
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
9558
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...
0
9378
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9331
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
9253
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6798
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...
0
6077
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3316
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

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.