RE: [Proto-Scripty] Re: Hide or Remove non-HTML element from HTML

2010-04-20 Thread Jonathan Rosenberg
How about using Xpath from Javascript to find the nodes?  Very simple.

--
Jonathan Rosenberg
Founder  Executive Director, Tabby's Place
http://www.tabbysplace.org/


-Original Message-
From: prototype-scriptaculous@googlegroups.com
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Jelks
Sent: Tuesday, April 20, 2010 9:39 AM
To: Prototype  script.aculo.us
Subject: [Proto-Scripty] Re: Hide or Remove non-HTML element from HTML

Let me rephrase the question...

Given that this is generated:

 form ...
   input ...
 AsyncExceptionError occured during AsyncInvocation./
AsyncException
   some more real html form stuff...
 /form

In the IE HTML DOM, that XML snippet becomes three nodes:

ASYNCEXCEPTION
#text  (Error occured during AsyncInvocation.)
/ASYNCEXCEPTION

Is there a way in IE to iterate through all the text nodes, and when
it find one that contains say AsyncInvocation, remove the whole text
node, or perhaps replace the whole text node with ?

So far I've always addressed text nodes through their parents/
wrappers, but maybe there is a way to address them directly?

Alternately, perhaps there is a way to address that ASYNCEXCEPTION
node and address the next sibling, which is presumably the text node,
and set it to blank.

I know this is an edge case and deals with IE weirdnesses, but perhaps
someone here has dealt with this before.

Many thanks,

Jelks

-- 
You received this message because you are subscribed to the Google Groups
Prototype  script.aculo.us group.
To post to this group, send email to
prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: Hide or Remove non-HTML element from HTML

2010-04-20 Thread Alex Wallace
The non-HTML element can be tricked into appearing to be an actual HTML
element if you use:

document.create(fakeElementTagName); somewhere on the page. Once that's
done, IE will treat fakeElementTagNamefoo-bar/fakeElementTagName as an
actual DOM element, and you should be able to remove it using regular DOM
helpers. (e.g. parentNode.removeChild, or Prototype's .remove();)

Try it out and let me know.

Best,
Alex

On Tue, Apr 20, 2010 at 10:33 AM, Jelks jelks.caban...@gmail.com wrote:

 On Apr 20, 10:08 am, Jonathan Rosenberg j...@tabbysplace.org
 wrote:

  How about using Xpath from Javascript to find the nodes?  Very simple.

 Simple?  How so?  This is not an XML document, this is an HTML page
 that happens to have one non-HTML element in it.  All the other
 browsers add it to the HTML DOM, no problem -- and in those, I can
 easily hide or remove it.  But IE turns that non-HTML element into
 three nodes, the start tag being the first, the text node being the
 second, and end tag the third.  Presumably the three are siblings, but
 I'm guessing there.

 So how might I go about removing that text node in an HTML document
 using Xpath from Javascript?

 Thanks,

 Jelks

 --
 You received this message because you are subscribed to the Google Groups
 Prototype  script.aculo.us group.
 To post to this group, send email to
 prototype-scriptacul...@googlegroups.com.
 To unsubscribe from this group, send email to
 prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/prototype-scriptaculous?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



RE: [Proto-Scripty] Re: Hide or Remove non-HTML element from HTML

2010-04-20 Thread Jonathan Rosenberg
Ok, so I was too glib.  Maybe it's not very simple.

1) Do you have control of the delivery of this document at the server side?
2) Is it well-formed XHTML?
3) I'm not sure I understand what you're trying to do with this page while
it's in a browser.  JIs it just to remove the text node

--
Jonathan Rosenberg
Founder  Executive Director, Tabby's Place
http://www.tabbysplace.org/



-Original Message-
From: prototype-scriptaculous@googlegroups.com
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Jelks
Sent: Tuesday, April 20, 2010 10:34 AM
To: Prototype  script.aculo.us
Subject: [Proto-Scripty] Re: Hide or Remove non-HTML element from HTML

On Apr 20, 10:08 am, Jonathan Rosenberg j...@tabbysplace.org
wrote:

 How about using Xpath from Javascript to find the nodes?  Very simple.

Simple?  How so?  This is not an XML document, this is an HTML page
that happens to have one non-HTML element in it.  All the other
browsers add it to the HTML DOM, no problem -- and in those, I can
easily hide or remove it.  But IE turns that non-HTML element into
three nodes, the start tag being the first, the text node being the
second, and end tag the third.  Presumably the three are siblings, but
I'm guessing there.

So how might I go about removing that text node in an HTML document
using Xpath from Javascript?

Thanks,

Jelks

-- 
You received this message because you are subscribed to the Google Groups
Prototype  script.aculo.us group.
To post to this group, send email to
prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



RE: [Proto-Scripty] Re: Hide or Remove non-HTML element from HTML

2010-04-20 Thread Rick . Wellman
I've only partially followed this thread so apologies if this was 
suggested/shotdown.
Can you wrap it with a well-formed HTML element? i.e. div (most likely) and 
remove it with javascript/prototype?

-Original Message-
From: prototype-scriptaculous@googlegroups.com 
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Jelks
Sent: Tuesday, April 20, 2010 10:36 AM
To: Prototype  script.aculo.us
Subject: [Proto-Scripty] Re: Hide or Remove non-HTML element from HTML



On Apr 20, 10:43 am, Jonathan Rosenberg j...@tabbysplace.org
wrote:
 Ok, so I was too glib.  Maybe it's not very simple.

 1) Do you have control of the delivery of this document at the server side?

Only somewhat.  If I had total control, I would not be letting this

AsyncExceptionError occured during AsyncInvocation./
AsyncException

arrive in and pollute the document.

 2) Is it well-formed XHTML?

Yes.  But it's served as text/html.

 3) I'm not sure I understand what you're trying to do with this page while
 it's in a browser.  JIs it just to remove the text node

Yes, to remove that text node (with *or without* it's bogus
ASYNCEXCEPTION and /ASYNCEXCEPTION apparently sibling nodes that
IE creates from that XML snippet above) -- in order that I don't see
this:

Error occured during AsyncInvocation.

at the top of the page in IE (no problem hiding it in Firefox/Chrome).

Thanks,

Jelks

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: Hide or Remove non-HTML element from HTML

2010-04-20 Thread Alex Wallace
In theory, yes. The three nodes is how IE represents supposedly invalid
DOM nodes. By utilizing document.createElement(fakeDomNodeName), the IE
DOM starts to think that those invalid nodes are in fact actual elements.

Using this technique allows you to use CSS to target and style
HTML5-specific elements that previously found themselves in the three
nodes malformation. [1]

So maybe if you try the document.createElement() method, you can use
Prototype to remove the nodes, or at least use CSS to set their { display:
none; }

http://ejohn.org/blog/html5-shiv/

Cheers,
Alex

On Tue, Apr 20, 2010 at 11:44 AM, Jelks jelks.caban...@gmail.com wrote:

 On Apr 20, 10:41 am, Alex Wallace alexmlwall...@gmail.com wrote:
  The non-HTML element can be tricked into appearing to be an actual HTML
  element if you use:
 
  document.create(fakeElementTagName); somewhere on the page. Once that's
  done, IE will treat fakeElementTagNamefoo-bar/fakeElementTagName as
 an
  actual DOM element, and you should be able to remove it using regular DOM
  helpers. (e.g. parentNode.removeChild, or Prototype's .remove();)

 Thanks Alex, so you're saying that with this toward the beginning of
 the form ...:

AsyncExceptionError occured during AsyncInvocation./
 AsyncException

 which appears in the IE DOM as

ASYNCEXCEPTION
#text  (Error occured during AsyncInvocation.)
/ASYNCEXCEPTION

 (where those are *three nodes* (!) and not *one element*), and which
 shows this at the top of the page:

Error occured during AsyncInvocation.

 that if I do

document.createElement(ASYNCEXCEPTION);

 it will somehow overwrite those three nodes???

 Thanks,

 Jelks

 --
 You received this message because you are subscribed to the Google Groups
 Prototype  script.aculo.us group.
 To post to this group, send email to
 prototype-scriptacul...@googlegroups.com.
 To unsubscribe from this group, send email to
 prototype-scriptaculous+unsubscr...@googlegroups.comprototype-scriptaculous%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/prototype-scriptaculous?hl=en.



-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: Hide or Remove non-HTML element from HTML

2010-04-20 Thread Walter Lee Davis
It's a shame that Firefox doesn't allow this. I was hoping to style an  
input type=search using this trick.


Walter

On Apr 20, 2010, at 12:11 PM, T.J. Crowder wrote:


@Jelks:

What Alex is saying that IE has the ability to let you *tell it* that
that's really an element. At the very beginning of your doc (in the
head section, ideally), put in this script element:

script type='text/javascript'
document.createElement(AsyncException);
/script

It may seem surprising, but your doing that adds to IE's element
vocabulary. Now, for the rest of the parsing of that page, IE will
know that AsyncException is a valid tagname for an element and will
treat it as one. Note that the script needs to be inline and evaluated
at the beginning, because this affects how IE parses the document (if
you do it after that bit's already been parsed, you'll still get the
structure you've been fighting with).

And once it's a normal element, it's a normal element susceptible to
styling, discovery by tag name, etc.:

style type='text/css'
AsyncException
{
   display: none;
}
/style

script type='text/javascript'
document.observe(dom:loaded, function() {
   $$('AsyncException').invoke('remove');
});
/script

So what I'd do is put in the style rule (so there isn't even a brief
moment people will see the text), and put in a script tag at the
beginning with the `createElement` call and setting up the dom:loaded
handler to actually remove it when the DOM is ready.

HTH,
--
T.J. Crowder
Independent Software Consultant
tj / crowder software / com
www.crowdersoftware.com


On Apr 20, 4:44 pm, Jelks jelks.caban...@gmail.com wrote:

On Apr 20, 10:41 am, Alex Wallace alexmlwall...@gmail.com wrote:

The non-HTML element can be tricked into appearing to be an actual  
HTML

element if you use:


document.create(fakeElementTagName); somewhere on the page. Once  
that's
done, IE will treat fakeElementTagNamefoo-bar/ 
fakeElementTagName as an
actual DOM element, and you should be able to remove it using  
regular DOM

helpers. (e.g. parentNode.removeChild, or Prototype's .remove();)


Thanks Alex, so you're saying that with this toward the beginning of
the form ...:

AsyncExceptionError occured during AsyncInvocation./
AsyncException

which appears in the IE DOM as

ASYNCEXCEPTION
#text  (Error occured during AsyncInvocation.)
/ASYNCEXCEPTION

(where those are *three nodes* (!) and not *one element*), and which
shows this at the top of the page:

Error occured during AsyncInvocation.

that if I do

document.createElement(ASYNCEXCEPTION);

it will somehow overwrite those three nodes???

Thanks,

Jelks

--
You received this message because you are subscribed to the Google  
Groups Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com 
.
To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com 
.
For more options, visit this group athttp://groups.google.com/group/prototype-scriptaculous?hl=en 
.


--
You received this message because you are subscribed to the Google  
Groups Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com 
.
To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com 
.
For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en 
.




--
You received this message because you are subscribed to the Google Groups Prototype 
 script.aculo.us group.
To post to this group, send email to prototype-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.