Does anyone know how to get the HTML out of an IFRAME I have tried several different ways:
document.getElementById('iframe01').contentDocument.body.innerHTML
document.frames['iframe01'].document.body.innerHTML
document.getElementById('iframe01').contentWindow.document.body.innerHTML
etc
...
I tried to set innerHTML on an element in firefox and it worked fine, tried it in IE and got unexpected errors with no obvious reason why.
For example if you try and set the innerHTML of a table to " hi from stu " it will fail, because the table must be followed by a sequence.
...
I have a HTML file that has code similar to the following.
<table>
<tr>
<td id="MyCell">Hello World</td>
</tr>
</table>
I am using javascript like the following to get the value
document.getElementById(cell2.Element.id).innerText
This returns the text "Hello World" with only 1 space between hello and world. I MUST kee...
I know innerHTML is supposedly evil, but I think it's the simplest way to change link text. For example:
<a id="mylink" href="">click me</a>
In JS you can change the text with:
document.getElementById("mylink").innerHTML = new_text;
And in Prototype/jQuery:
$("mylink").innerHTML = new_text;
works fine. Otherwise you have to rep...
I'm trying to fix a bug in a rich text editor I'm using, which causes <embed> tags to be inserted without their closing tag (which screws the output up completely). I've isolated the problem to this operation:
// body is a <body> tag
body.innerHTML = '<embed src="http://example.com/whatever"></embed>';
No fancy code, just Fir...
function DeleteData(ID)
{
var ctrlId=ID.id;
var divcontents=document.getElementById(ctrlId).innerHTML;
var tabid=ctrlId.replace(/div/,'tab');
var tabcontents=document.getElementById(tabid).innerHTML;
alert(document.getElementById(tabid).innerHTML);
document.getElementById(tabid).innerHTML="<TBody><tr><td></td></tr><tr><td></td></t...
The setup:
I have a suckerdiv menu with links that call a function. Said function looks like:
function F(string)
{
var s = '';
var c = '';
var t = '';
if(string == 'cat')
{
s = "cat";
c = "animal";
t = "fluffy";
}
// ...
document.getElementById("title").innerHTML = t;
document....
What is the best plain javascript way of inserting X rows into a table in IE.
The table html looks like this:
<table><tbody id='tb'><tr><td>1</td><td>2</td></tr></tbody></table>
what i need to do, is drop the old body, and insert a new one with 1000 rows. i have my 1000 rows as a javascript string variable.
the problem is that table...
If you set the innerHTML of a <div> to innerHTML = '<a href="Something/C%23">C#</a><br />';
What seems to actually get 'rendered' is:
<div>
<a href="Something/C#">C#</a><br />
</div>
What is the proper way to escape this so the link will stay "Something/C%23" ?
UPDATE:
I noticed a weird little thing here. If you use a function to b...
<noscript><div id="example">I want to get this innerHTML</div></noscript>
<script type="text/javascript"> alert($('example').innerHTML);</script>
This javascript snippet just returns an empty string. Is there a way of getting the contents of a noscript node?
p.s. I'm using prototype on this particular project.
...
I'm trying to split the innerText of a div on the newlines in the source for it. This works fine with:
$('div').text().split("\r\n|\r|\n")
But this fails in IE 7, due to the newlines apparently being stripped out. jQuery 1.3.2 doesn't appear to be at fault since i also tried both:
$('div')[0].innerText.split("\r\n|\r|\n")
and
$('d...
I'm wondering if there's a way to change the text of anything in HTML without using innerHTML.
Reason I'm asking is because it's kinda frowned upon by the W3C.
I know it's nitpicking, but I just wanna know, is there a way?
EDIT: people seem to misunderstand what I'm asking here: I want to find a way to effectivly change the text being ...
I have a page where there's a drag and drop table where the order of the rows determines the value of a subtotal. However, it's more complicated than just addition and I would rather not duplicate the logic in JavaScript to update the values.
A simple solution would be to reload the whole page using Ajax and then replace the table from ...
If you open a text file (.txt, .js, .css, ...) in your browser, it will get wrapped up in a nice DOM tree.
For example, open this .txt file and enter
javascript:alert(document.documentElement.innerHTML);
into your address bar. Nice... every major browser supports DOM manipulation on this wrapped text files, which is a great thing for...
If I have a
var t = document.createTextNode(text)
parent.appendChild(t);
Is it possible to simply update the contents of t?
I would like to change the text inside the parent without using removeChild, createTextNode and appendChild. Why would I need this instead of just using innerHTML? Because I don't want to update the contents of ...
I'm using Sharepoint (WSS 3.0), which is unfortunately very limited in its ability to format survey questions (i.e., it strips any HTML you enter). I saw a solution elsewhere that suggested we add some JS to our master page file in order to allow line breaks. This works beautifully, but I'd like to see if we can allow links as well.
In...
Hello everyone,
I am trying to get some data from the server via an AJAX call and then displaying the result using responseDiv.innerHTML. The data from the server comes partially encoded with Unicode elements, like: za\u010Dat test. By setting the innerHTML of the response div, this just displayed as is. That is, the Unicode is not conv...
Hi,
I'm trying to do the following (I'm using the prototype library):
var div = document.createElement('div');
div.innerHTML = '<script src="somescript.js"></script>';
$('banner').insert(div);
In IE, div.innerHTML property is always equal to "" after I set the property in the second line.
This snippet is inside a function which is o...
Hi StackOverflow,
This is a long one,
The Premise
Was called in to help out a client with some bug fixing on a current project of theirs. What needed fixing was a jobs listing page. You have a list of jobs, you click one and if JavaScript is activated an AJAX call is made to dynamically load the job's details into an existing element ...
I am trying to add to all <object>'s on a page a snippet of html. I understand I can access elements by tag name and that I can change the element, but can I simple append to it instead?
In addition, I want to add it to the contents of each tag, not the end of the document. Which of these methods will work?
...