By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,453 Members | 961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,453 IT Pros & Developers. It's quick & easy.

Nullyfing events in a HTML

P: n/a
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

Aug 11 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a

<c.**********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
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
Aug 11 '05 #2

P: n/a

Darren wrote:
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?
Darren


Aug 11 '05 #3

P: n/a

<c.**********@gmail.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...

Darren wrote:
have you considered doing it serverside?
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. Darren

Aug 11 '05 #4

P: n/a
c. anandkumar wrote:
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
Aug 12 '05 #5

P: n/a
VK

c.**********@gmail.com wrote:
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/default.asp?url=/workshop/author/dhtml/reference/methods/setcapture.asp>
It will not prevent key events, but mouse events will be killed.

Aug 12 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.