JQuery :: Get The OuterHTML Of A Html Object?
Jun 13, 2007anyone else get the outerHTML of a html object? I can't seem to get it anymore. document.getElementById('log').outerHTML returns undefined.
View 4 Repliesanyone else get the outerHTML of a html object? I can't seem to get it anymore. document.getElementById('log').outerHTML returns undefined.
View 4 RepliesFound here: [URL]
Code:
jQuery.fn.outer = function() {
return $( $('<div></div>').html(this.clone()) ).html();
}
Usage:
alert( $("#toolbar #save").outer() );
In understanding how this works, would it not be possible then to replace an
item with another?
For instance, I have the first paragraph of "Lorem Ipsum" shown in a
division.
At the bottom is a ling showing "next".
Click on the link, the next paragraph replaces te previous.
<p id="lorem1">lorem ipsum stuff.</p>
<p id="lorem2">paragraph 2 stuff.</p>
I attempted to use the "Textual tooltip" swapping routine at Dynamicdrive,
but the code killed the other script for the menu.
What I'm looking for is a simple swap method, like image swapping, without
the use of z-index.
Also, if outerhtml is a solution to my problem, then could I have all the
paragraphs needed on an external page so that the various paragraphs do not
load with the main page?
If you must have a reference see www.somestuff.batcave.net/menu1.html
I discovered how to write out the inner HTML of the contents of an
Iframe; I want to know how to write out the outerHTML of the contents
of an Iframe.
frames['iframeid'].document.body.innerHTML allows me to read the inner
HTML of the contents of an iframe and also allows me to write out the
inner HTML of the contents of an iframe.
However using frames['iframeid'].document.body.innerHTML I am only able
to change, in the contents of the iframe, the code in between and
including the body tags; I am not able to change the code above the
body tag such as what is in the head section and what is in the html
tag.
The problem is, that other maneuvers that allow me to read the contents
of an iframe, do NOT allow me to write out the contents of the iframe.
These are:
frames['framid'].document.body.outerText
frames['framid'].document.body.innerText
frames['framid'].document.documentElement.outerHTML
The problem persists if the page originally loaded into the iframe
contains no code.
This looks like an unpredictable inconsistency of the type that makes
Javascript a language to be learned through experimentation. Or is
there some documentation somewhere that lists the read/write abilities
of such lines of code?
I'm trying to create a bookmarklet on IE6, that passes the outerHTML of the body element as a GET param my site.
The problem is that for some page (ie mail.yahoo.com) the bookmarklet does not work while for other pages (simpler ones) it does work....
I'm building a webpage using javascript and iframes. Basically I have an iframe in the middle of the index.html page that links to another html page (let's call it iframe.html). My question is, is it possible to call a javascript function from iframe.html to control an object on index.html? If so, how do I do this? I'd like to be able to assign an image in iframe.html with the hyperlink of href="javascript:function()", where the function effects the CSS of a div on index.html.
View 2 Replies View RelatedI'm using the JQuery Template plug-in found here : [URL]..When I run my code as such:
$("#resulttmpl").render(result).appendTo("#resultdata"); Things work fine. However in my situation I need to get the actual HTML rendered into a variable. I've tried:
$("#resulttmpl").render(result).html();
$("#resulttmpl").render(result).value();
$("#resulttmpl").render(result).text();
However none seem to be doing what I need (bringing back the full html). I've tried to debug what object is returned from .render() but I'm stuck. It looks like some sort of array. I've attached a picture from FireBug.
I'm using the modern equivalent of an iframe...
<object data="page.html" type="text/html" id="myiframe"></object>
and i want to change the the iframe's contents. In the past, with real iframes, i'd have...
<iframe src ="page.html" id="myiframe"></iframe>
and the jQuery to change its contents...
$('body', $('#myiframe').contents()).html(myNewHtml);
...which worked perfectly. Not so with this new object type of iframe. Anybody know how the hell to do it??
i'm trying to find out how to edit (manipulate DOM) of an HTML ajaxresult.
What i have is the following :
$('a').live('click',function(e){
var link = this;
[code]....
How do I go about comparing two jquery objects to see if they're actually the same html object.
I've got:
This should add a border to every object in the selected set except for the one defined in someobject... shouldn't it.
My background is C++ and C#. Using basic selectors and filters in jQuery is not a problem for me. My problem is finding the right jQuery code to capture a live html page and assign an object which contains all the html text I just captured... then I can use the object to apply basic selector and filter functions to create another page.
View 6 Replies View RelatedI have an piece of html in a jquery object. When I say $(this).html I get:
<span class="value">4</span><span class="type">teaspoons</span>butter
I want to get only the piece of text from this html segment that is not in the spans. in this example, it is butter.
How do I get that?
I have array elements referenced to HTML objects:
myArr[0] = document.getElementById("myDiv1");
myArr[1] = document.getElementById("myDiv2");
How do I reference to these HTML objects through array using object's
properties to make something like:
myArr["some_proprty_here"].innerHTML = "div content changed"
I know this can be done but I do not see how.
How can I change the cursor type, when I am over a html element. (on tableCell - I want to make a cursor that is like a hand and not an arrow).
View 4 Replies View RelatedI have this simple code here:
var container = document.getElementById(con);
var obj = container.getElementsByTagName('img');
And I want to get the full HTML image tag using the obj value, if you get what I mean. So I want to get this:
<img src="images/image_209948045.jpg" />
by using this: obj[0];
I have this code that load HTML tags (no including <html> or <body>)
into a DIV dinamically...
after correctly retrieving the HTML, I assign it to my DIV Container
document.getElementById(containerid).innerHTML=pag e_request.responseText
now from main page....I need to get a reference to an Object (a
textbox) contained in the dinamically loaded HTML
Once in my main document this, doesn't works:
document.getElementById(containerid)
The objects that I loaded dinamically, are part of the Main Document or
not? How can I access this objects from my main page?
after i've built an element, can i convert that element to html? the current method i'm thinking is to append this element to a new <Div> and call the Div's innerHTML but it feels rather dirty. is there a better solution?
View 2 Replies View RelatedI have a HTML table with combobox option in one of the column.when I select a value in dropdown the background color changes to red or green based on the selction.My Code looks like :
function OnHTMLTable1_ClickLink ( ) {
var irows = document.getElementById("HTMLTable1").getElementsByTagName('tr');
var iRowCount = irows.length;
for(i=0; i<=iRowCount; i++)
[Code].....
When I select a value it is throwing me "Object Required error".
First, with AJAX I will get a remote web page into a string. Thus, a
string will contain HTML tags and such. I will need to extract text
from one <span> for which I know the ID the inner text.
Is it possible to access in this way "string variable".getElementByID()
somehow?
PS: Just thinking of a proper/efficient way to extract the information
from such a string. I am open to other ideas. I could load that page in
IFRAME and get my access to DOM that way, yet probably it is not an
eligant solution.
I had a problem with my previous approach in javascript so i thought of another strategy, to work with java. How can i pass the DOM of the current web page that is the HTML page to java, so that i can parse the DOM and i need to extract the internal contents of the script tags in the page and evaluate them apart from running in the webpage.
How can i pass the dom object to java and evaluate the scripts contents from java.
I'm developing a web app in which I have a file upload option. The thing is, my file input is hidden, and instead, a textbox and a button are used, in order to style the input, copy the file input's value and allowing the user write a link address into the textbox (the php upload page recognizes the text in the textbox and takes action if the text is a hyperlink or a file upload).
The problem is, when I submit the form, the php is catching the file input's value as empty. So I removed the hidden property of the file input, in order to check what was wrong, and I noticed the input's value is being reset on form submit. When not hidden it takes me two button clicks to submit the form, being the first one the responsible for cleaning the file input. Though, if I assign it's value directly from the input object, it works perfectly.
Here's the code:
I am working on a website that will contain YouTube Photoshop tutorial videos which I am creating.
The videos will be added as embedded objects. I want to use a dropdown menu so the user can select which video will appear. The video itself will be contained inside of a single table cell. The content of that cell will depend on which video is selected in the dropdown.
Is there a way to do this? I have some javascript experience but I am for sure still a novice. Also, is there a link to a sample script that would be similar to what I am trying to do? I've been searching the internet but I haven't found anything similar to this yet.
13 line causes this exception. Function is called insied of ready() handler. function renderGridSystemRecursively(scheme, container){
[Code]...
I am trying some simple things with javascript and trying to use it in a object oriented way. However I am now facing a problem in which I can't access an object variable from an object method. I am using jQuery.
My code is as follows;
Code:
My problem is that the variable msg1 does not work when accessed from function called from the jQuery get function. I get the message undefined. Therefore I am wondering, is there a way how I can access msg1 of my object instance from the get function of jQuery?
how to add extra properties to html elements as I was storing data in html attributes. After looking at some others code including Raphael and this addEvent code. [URL] They seem to treat objects just like an array. obj[property] = value; This would have been extremely helpful to know previously as I have needed to be able to include variables in property names - but have resorted to making the whole thing a string and calling exec() on it.
View 2 Replies View RelatedI'm trying to create an onClick that will change an embedded html page. I'm using the same syntax that works for both <img> and <iframe>.
Code:
<object id="thing" data="page1.html" type="text/html">
error message
</object>
[Code]....
There must be some fundamental difference between changing an image or iframe "src" and changing an object's "data" that totally escapes me because the above script won't update/refresh/reload/change the existing embedded page (page1.html) to page2.html.
I have run the script with an "alert(document.getElementById('thing').data)" tacked onto the end of the above script, and it does, in fact, return "page2.html" in the dialogue box. So, maybe, I just need to refresh the object (without reloading the whole page!)?
I've noticed that <object> is usually used with applets and flash and sound and there seem to be commands to "run" them, but I can't find any terms to handle updating an embedded html document. Maybe there really just isn't any way to do this yet aside from iframe?