/    Sign up×
Community /Pin to ProfileBookmark

innerHTML idnt working

i have an iframe to which i load a page witha <SELECT>
and i use a function to d/l to that iframe a page with a select!
now after the page d/l into the iframe i want to copy the select from the iframe to the div like this :

[code=php]document.getElementById(“divSearchResult”).innerHTML=document.getElementById(“ifrmHoldData”).innerHTML; [/code]

but it isnt working!
why?
thnaks i nadvance
peleg

to post a comment
JavaScript

14 Comments(s)

Copy linkTweet thisAlerts:
@sciguyryanAug 19.2004 — Did you put it [b]after[/b] the elements were defined in the HTML page because that is the common cause of these problems.




RyanJ
Copy linkTweet thisAlerts:
@TheBearMayAug 19.2004 — This [code=php]document.getElementById("ifrmHoldData").innerHTML[/code] will only yield what is present between the iFrame tags, ie.

[code=php]
<iframe id="ifrmHoldData" ...>Dummy Text</iframe>
<script type="text/javascript">alert(document.getElementById("ifrmHoldData").innerHTML);</script>[/code]
will display "Dummy Text".

If you want to take the file that the src attribute of the iFrame was set to, you can use this script that Vladdy posted sometime ago and pass it the file name:

[code=php]function getFile(fileName){
oxmlhttp = null;
try{
oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/xml");
}
catch(e){
try{
oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
return null;
}
}
if(!oxmlhttp) return null;
try{
oxmlhttp.open("GET",fileName,false);
oxmlhttp.send(null);
}
catch(e){
return null;
}
return oxmlhttp.responseText;
}[/code]
Copy linkTweet thisAlerts:
@pelegk1authorAug 19.2004 — and second u actually say that if there wasnt anything between the ifrane tags from starts,whatever i will load into the iframe later isnt accessible?
Copy linkTweet thisAlerts:
@pelegk1authorAug 19.2004 — Did you put it after the elements were defined in the HTML page [/QUOTE]
Copy linkTweet thisAlerts:
@TheBearMayAug 19.2004 — Not impossible, just not as easy. I've had some success if I create a DIV with an associated ID and then do a getElementById on the new ID later...

I need to check to see if I actually still have it and that it works, but it seems to me that at one time I had some code that would add childNodes to an iFrame and then you could use innerHTML. I'll have to look ...
Copy linkTweet thisAlerts:
@nitwitAug 19.2004 — http://www.dyn-web.com/dhtml/iframes/

Scroll down to: "Using an Iframe as a Buffer"
Copy linkTweet thisAlerts:
@VladdyAug 20.2004 — Who needs damn frames :rolleyes:
<i>
</i>function file2div(fileName,div)
{ var oxmlhttp = null;
try
{ oxmlhttp = new XMLHttpRequest();
oxmlhttp.overrideMimeType("text/xml");
}
catch(e)
{ try
{ oxmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{ return null;
}
}
if(!oxmlhttp) return null;
try
{ oxmlhttp.open("GET",fileName,false);
oxmlhttp.send(null);
}
catch(e)
{ return null;
}
var dbody = /&lt;s*body.*?&gt;([x00-xff]*)&lt;s*/bodys*&gt;/.exec(oxmlhttp.responseText);
if(dbody &amp;&amp; dbody[1]) dbody = dbody[1];
try
{ df = (new DOMParser()).parseFromString(dbody, "text/xml");
div.appendChild(df);
}
catch(e)
{ try
{ div.innerHTML = dbody;
}
catch(e)
{ return null;
}
}
return true;
}
Copy linkTweet thisAlerts:
@pelegk1authorAug 22.2004 — second : Vladdy :

but what do i do if the activeX option is blocked at the user's browser?

then he will recive an error!
Copy linkTweet thisAlerts:
@neil9999Aug 22.2004 — Vladdy, are you ill? That's the first time I've ever seen you use innerHTML!

http://www.webdeveloper.com/forum/showthread.php?s=&threadid=32137&highlight=innerHTML

[i]Originally posted by pelegk1 [/i]

[B]but what do i do if the activeX option is blocked at the user's browser?

then he will recive an error! [/B]
[/QUOTE]


You'd also get an error if javascript is disabled in the browser.

Neil
Copy linkTweet thisAlerts:
@VladdyAug 22.2004 — LOL, never say never.....

In this particular case, I had to get down to the level of sub-par HTML renderer, [b]but only after I tried to do the right thing[/b]

peleg, you do the same thing as when JS is disabled or one uses browser that does not implement xmlhttp at all - rely on default page behavior, which you should have started with.
Copy linkTweet thisAlerts:
@neil9999Aug 22.2004 — [i]originally posted by Vladdy in another thread:[/i]

[b]There is never a need to use innerHTML. DOM methods accomplish the task much better.[/b][/quote]


Isn't there a dom method for this?

Neil
Copy linkTweet thisAlerts:
@VladdyAug 22.2004 — Yes, there is, but IE, once again, does not support it:
<i>
</i> try // DOM method first
{ df = (new DOMParser()).parseFromString(dbody, "text/xml");
div.appendChild(df);
}
catch(e) // If failed
{ try // innerHTML
{ div.innerHTML = dbody;
}
catch(e)
{ return null;
}
}
Copy linkTweet thisAlerts:
@JPnycAug 22.2004 — How can that be a DOM method if innerHTML is not a standard? Or is it part of the JS DOM, and just not a w3c web standard?
Copy linkTweet thisAlerts:
@steelersfan88Aug 22.2004 — In Vlad's script, the innerHTML catches the errors in browsers like IE that do not fully support DOM, which takes precedence in occurring. The innerHTML only occurs if the DOM fails, as the comments show.
×

Success!

Help @pelegk1 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...