Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
createContextualFragment
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Yansky  
View profile  
 More options Feb 16 2008, 9:20 pm
Newsgroups: comp.lang.javascript
From: Yansky <thegoodd...@gmail.com>
Date: Sat, 16 Feb 2008 18:20:32 -0800 (PST)
Local: Sat, Feb 16 2008 9:20 pm
Subject: createContextualFragment
I posted this over at netscape.public.mozilla.dom but the group seems
to be dead, so I figured I'd repost my question here:

I was just wondering why createContextualFragment is available in
Mozilla browsers when they also have innerHTML which seems to do
exactly the same thing?

http://developer.mozilla.org/en/docs/DOM:range.createContextualFragment

Cheers.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Paul Wilkins  
View profile  
 More options Feb 16 2008, 11:43 pm
Newsgroups: comp.lang.javascript
From: Paul Wilkins <pmw5...@gmail.com>
Date: Sat, 16 Feb 2008 20:43:28 -0800 (PST)
Local: Sat, Feb 16 2008 11:43 pm
Subject: Re: createContextualFragment
On Feb 17, 3:20 pm, Yansky <thegoodd...@gmail.com> wrote:

> I posted this over at netscape.public.mozilla.dom but the group seems
> to be dead, so I figured I'd repost my question here:

> I was just wondering why createContextualFragment is available in
> Mozilla browsers when they also have innerHTML which seems to do
> exactly the same thing?

> http://developer.mozilla.org/en/docs/DOM:range.createContextualFragment

Sometimes IE wins, as with innerHTML vs createContextualFragment
Sometimes IE loses, as with document.all s document.getElementById
Sometimes two competing ideas don't win out, as in addEventListener
and attachEvent

--
Paul Wilkins


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
dhtml  
View profile  
 More options Feb 17 2008, 12:36 am
Newsgroups: comp.lang.javascript
From: dhtml <dhtmlkitc...@gmail.com>
Date: Sat, 16 Feb 2008 21:36:46 -0800 (PST)
Local: Sun, Feb 17 2008 12:36 am
Subject: Re: createContextualFragment
On Feb 16, 8:43 pm, Paul Wilkins <pmw5...@gmail.com> wrote:

Can you do dynamic script insertion with that?

var s = "<script>alert(1)</script>";
var range = document.createRange();
range.selectNode(document.body);
var documentFragment = range.createContextualFragment(s);
document.body.appendChild(documentFragment);

It looks like you can.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Martin Honnen  
View profile  
 More options Feb 17 2008, 9:13 am
Newsgroups: comp.lang.javascript
From: Martin Honnen <mahotr...@yahoo.de>
Date: Sun, 17 Feb 2008 15:13:07 +0100
Local: Sun, Feb 17 2008 9:13 am
Subject: Re: createContextualFragment

Yansky wrote:
> I was just wondering why createContextualFragment is available in
> Mozilla browsers when they also have innerHTML which seems to do
> exactly the same thing?

> http://developer.mozilla.org/en/docs/DOM:range.createContextualFragment

createContextualFragment in Mozilla was first, then innerHTML support
was implemented with the help of createContextualFragment.
createContextualFragment by now works for XML documents too where you do
not have innerHTML e.g.

   var xmlDoc = new DOMParser().parseFromString(
     '<root><foo/></root>', 'application/xml');
   var node = xmlDoc.documentElement.getElementsByTagName('foo')[0];
   var range = xmlDoc.createRange();
   range.selectNode(node);
   var fragment = range.createContextualFragment(
'<bar>foobar</bar><!-- comment -->');
   node.appendChild(fragment);
   alert(new XMLSerializer().serializeToString(xmlDoc));

--

        Martin Honnen
        http://JavaScript.FAQTs.com/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »