473,387 Members | 1,899 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.

Object for iframe not being created

3
Hi Experts,
I am trying this bit of code which is not working right.

<script language="JavaScript" type="text/JavaScript">
<!--
function showHide(divName)
{
var x = new getObj(divName);
document.writeln(x.name);
//document.writeln(x.value);
}
//-->
</script>
__________
document.getElementById("statusUpdate").innerHTML += "<input type='checkbox' id = 'demogexcel' name='demogexcel' value='DEMOG' onClick='showHide(\"demog\")'>&nbspYes/ No </td> ";

document.getElementById("statusUpdate").innerHTML += "</tr><tr width='100%'><td width='100%' colspan='4' valign='middle' class='verdanablue'>";

document.getElementById("statusUpdate").innerHTML += "<iframe id=\"demog\" name=\"demog\" display='none' width='100%;' height='100px' border= '0px' bgcolor='e6e8ed' scrolling='yes' FRAMEBORDER=0 ></iframe></td>";

document.getElementById("statusUpdate").innerHTML += "</tr></table>";

Here, when the checkbox created innerHtml named demogexcel is clicked, the showHide function is called. I have also confirmed that demog value is passed to it correctly. However the line var x = new getObj(divName); does not create an object for the iframe - demog. Please can anybody help me with this.
I have also tried putting the name of the iframe in singlequotes.

I have tried the similar thing in another asp and it works perfectly fine, but in that case the iframe is created simple in a table and not in innerhtml of any object.

Is there any other alternative to doing this?

Thanks,
K
Jul 13 '07 #1
5 1604
gits
5,390 Expert Mod 4TB
hi ...

you have the getObj-method because you are using dreamweaver? what error occurs in firefox's or mozillas js-console? ...

kind regards
Jul 13 '07 #2
Ketty
3
Hi,
I am testing this code in IE 6.0 and the code does not give any error
The basic functionaltiy that I want to achieve is
1. Ask the user if he wants to upload an excel spreadsheet with the 'demogexcel checkbox'.
2. If the user checks the checkbox, I have written the code to upload the excel in another asp page which I want to display in the 'iframe demog'
3. I also tried the following - in showhide(divName) funtion and it works fine.

var x = new getObj("demog");
alert(x.obj.id); // displays the id of the iframe correctly.

But the below 2 lines dont work but also do not give any error
x.style.display = "";
x.src="www.google.com";

Am I doing something wrong??
The same thing works fine in another asp where the iframe object is created normally and not in the innerHTML code.
Hope I have explained my problem well.

Thanks!
Jul 13 '07 #3
gits
5,390 Expert Mod 4TB
do you see the iframe? in case you don't see it ... perhaps you pm me the generated html-page and i'll have a look about it ... when it's not too much code you may post it here instead ... may be there is something wrong with the dom that you create with innerHTML?

kind regards
Jul 13 '07 #4
Ketty
3
Hi Gits,

Yes, I do see the iframe.
The showHide(divName) function is also called properly with iframe value demog.
Infact when I tried
var x = new getObj(divName);
alert(x.obj.id); // this line displays the id of the iframe correctly.
But
x.src="www.google.com"; // this line does not give any error but does not execute properly.

How can I send you the entire code, if possible. Its too big to paste it here.

Thanks,
K
Jul 16 '07 #5
gits
5,390 Expert Mod 4TB
hi ...

as far as i can see from the code you sent to me it works like the following (i do it with pseudocode ... its really a lot of code otherwise ;) ):

Expand|Select|Wrap|Line Numbers
  1. <script>
  2.     // here are some scripts defined the following method too
  3.     function showHide(divName) {
  4.         // do something
  5.     }
  6. </script>
  7. <body>
  8.     <script>
  9.         // the problem is here !!! when you use document.getElementById();
  10.         // this will be executed during load where the dom is not really 
  11.         // (reliable) ready yet so the solution is to put it in a function in your 
  12.         // above script-area and call that function with onload of the body 
  13.     </script>
  14. </body>
  15.  
read the comments in the above pseudocode ... i think you will understand the problem and the solution ;) and i discovered that 'demog' is a duplicate id for a table and your iframe ... when making it unique ... it worked for me ... so:

first: make the id unique
second: try to put all js-operations with getElementBy...() in onload

kind regards
Jul 19 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: John Chen | last post by:
I need to use iframe to create a floating frame. But the contents in the iframe is not a external html file. Rather, it will be dynamically created by jsp. How can I set the src attribute to a URL...
7
by: Christopher J. Hahn | last post by:
I'm trying to use a script-generated form to submit to a script-generated iframe. The problem I'm running into is that the iframe is not assuming the name I assign it. IE6 on Win2000. FF1.0.2+...
2
by: Robert Oschler | last post by:
I have an IFrame whose document is created completely by Javascript code at runtime. The document in the IFrame accesses Javascript functions in the top level document. This works fine most of...
3
by: webEater | last post by:
Hi I have a problem with a piece of javascript. i am working on a workaround for non ajax compatible browser like ie 5/6 without activeX and opera8- I use dynamically created iframes and...
1
by: XP | last post by:
Hello Everyone, I was stuck with this really frustrating problem for sometime. Let me explain what I am trying to achieve: There is a form and an inner iframe. The form's target is set to the...
0
by: mem | last post by:
Hello, I'm a novice at this and am trying to solve a problem reference IFrame. The following code is for a page I've created. It works well with two exceptions. The IFrame is an application hosted...
1
by: John L. | last post by:
How do I invoke the scroll() method of a window object for a scrollable IFRAME element in an HTML document? I am using IE 7.0, and I thought the following would work: ...
23
by: vunet | last post by:
It is recommended by some sources I found to create IFrames in IE using document.createElement('<iframe src="#">') instead of document.createElement('iframe'). Why and what browser versions to...
2
by: tridirk | last post by:
Hi; I am getting a Objceted Expected Error on my forum site. I can't find what is wrong? Line: Char: Error: Object expected Code:0 the site is My SMF Forum
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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.