Nullyfing events in a HTML

C

c.anandkumar

Hi All -

I am trying to do the following,
1. Get a piece of HTML from a db
2. Display it on my page
with a requirement - clicking on any links in that HTML should not take
me away from the page.

This does not only include links which are formed by <a>nchor tags, but
also other ways of doing it, like,
<span onClick='location.href="http://someurl"'> Blah blah..
</span>

In other words, all the events that can be raised by this piece of html
should be blocked.

Setting all the 'onClick's and 'href's to "#" or blank string is
probably a good idea to start with, but the list of all such possible
causes for an event to be raised, may not be very straightforward to
compile.

I was wondering if there could be any way to nullify/block the events
that can be raised by such a piece of HTML.

Thanks for your input

- Anand
 
D

Darren

Hi All -

I am trying to do the following,
1. Get a piece of HTML from a db
2. Display it on my page
with a requirement - clicking on any links in that HTML should not take
me away from the page.

This does not only include links which are formed by <a>nchor tags, but
also other ways of doing it, like,
<span onClick='location.href="http://someurl"'> Blah blah..
</span>

In other words, all the events that can be raised by this piece of html
should be blocked.

Setting all the 'onClick's and 'href's to "#" or blank string is
probably a good idea to start with, but the list of all such possible
causes for an event to be raised, may not be very straightforward to
compile.

I was wondering if there could be any way to nullify/block the events
that can be raised by such a piece of HTML.

Thanks for your input

- Anand
have you considered doing it serverside?

Darren
 
C

c.anandkumar

Darren said:
have you considered doing it serverside?
You mean setting the href targets to blank values? Yeah, I did, but
even in that case, I will have to find out that part of the HTML which
is active. By active, I mean that HTML which is a hyperlink or a div
with a onMouseMove attribute attached to it or anything. Finding out
all such pieces will require a lot of work. Could there be a simpler
way?
 
D

Darren

You mean setting the href targets to blank values?
No i mean parsing the page with a serverside script such as with php or
perl. there 'seems' to be a lot more you can do with these.
Yeah, I did, but
even in that case, I will have to find out that part of the HTML which
is active. By active, I mean that HTML which is a hyperlink or a div
with a onMouseMove attribute attached to it or anything. Finding out
all such pieces will require a lot of work. Could there be a simpler
way?
Your looking at doing it from DOM? I would have thoought it would have been
easier parsing it as text then all you have to do is seek out "href" then
replace anything in quotes after that with #
Just my twopenneth worth.
 
R

Robi

c. anandkumar said:
Hi All -

I am trying to do the following,
1. Get a piece of HTML from a db
2. Display it on my page
with a requirement - clicking on any links in that HTML should not take
me away from the page.

This does not only include links which are formed by <a>nchor tags, but
also other ways of doing it, like,
<span onClick='location.href="http://someurl"'> Blah blah..
</span>

In other words, all the events that can be raised by this piece of html
should be blocked.

I use "The Proxomitron" for that purpose, although, sadly, it is not being
supported anymore, due to the passing away of its creator.

Just in case, here's the link:
http://www.proxomitron.info/

Setting all the 'onClick's and 'href's to "#" or blank string is
probably a good idea to start with, but the list of all such possible
causes for an event to be raised, may not be very straightforward to
compile.

I was wondering if there could be any way to nullify/block the events
that can be raised by such a piece of HTML.

The filter can be configured in a very colorful variety for all tastes...

HTH
 
V

VK

Hi All -

I am trying to do the following,
1. Get a piece of HTML from a db
2. Display it on my page
with a requirement - clicking on any links in that HTML should not take
me away from the page.

This does not only include links which are formed by <a>nchor tags, but
also other ways of doing it, like,
<span onClick='location.href="http://someurl"'> Blah blah..
</span>

In other words, all the events that can be raised by this piece of html
should be blocked.

For FF and Co you can use addEventListener('event',true) to capture
events from the top.

For IE5.5 and higher you can use setCapture() method:
<http://msdn.microsoft.com/library/d...author/dhtml/reference/methods/setcapture.asp>
It will not prevent key events, but mouse events will be killed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top