473,399 Members | 3,401 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

rightclick "openlink" bypasses important javascript

Recently I noticed that if you "right click" and "open link" on my
site, you bypass the javascript code that fires "onclick". I have
several pages that fall victim to this, and I could probably refractor
the page and put checking on both javascript and cs side but before I
did that I wanted to know if there were any other ideas on how to get
around this problem.

I started out by trying to disable the right click, but I don't want
to have an "alert" pop up, I tried fired the "onclick" command on
right click events but this just had an error message pop up, then
still allowed me to still select "open link" from the context menu.

Thanks for you help

Jun 26 '07 #1
1 1445
* je******@smartvoicecast.com wrote, On 26-6-2007 23:16:
Recently I noticed that if you "right click" and "open link" on my
site, you bypass the javascript code that fires "onclick". I have
several pages that fall victim to this, and I could probably refractor
the page and put checking on both javascript and cs side but before I
did that I wanted to know if there were any other ideas on how to get
around this problem.

I started out by trying to disable the right click, but I don't want
to have an "alert" pop up, I tried fired the "onclick" command on
right click events but this just had an error message pop up, then
still allowed me to still select "open link" from the context menu.

Thanks for you help
You cannot really force the script to fire. Remember that there might be
browsers with Javascript disabled, or people just copy/pasting the link
and opening it. If you want to be certain use a LinkButton instead of a
Hyperlink and in the LinkButton.Click server side event do a
Response.Redirect to the new url.

Alternatively you can make the link itself a javascript url like this:

<a href="javascript:if(DoSomevalidation()){window.loc ation.replace('new
url here');}">click me</a>

But this will break the site altogether if you've got scriptless
browsers visiting your website.

Jesse
Jun 29 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

53
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is...
2
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing...
9
by: Sarah | last post by:
Hi! I have perhaps a strange question... I have a javascript that activates on a right click and shows the user a little menu of links. However, by doing so, it disables the users ability to...
8
by: Rob McLennan - ZETLAND | last post by:
Hi, I have set up an external stylesheet, named "print.css", to format the style of all pages printed from my company's website. I've been previewing my changes to the stylesheet by doing...
8
by: Ken Yu | last post by:
Hi, How can i disable "RightClick Menu" in Internet Explorer, when access the frontpage ? tks a lot ! Ken
0
by: Peter van der Veen | last post by:
Hi I have a treeview and a bound contextmenu to delete a node. When the user rightclicks the node the menu pops up and one can chosse delete. So far so good. But .... When i use...
5
by: rishabhshrivastava | last post by:
Hi All, I am using a Web Application and I want to customize Right Click Menu as following:- Do Nothing when user does a Right Click. When user select some text and does a Right Click he/she...
1
by: buss123 | last post by:
Hi to all , pls tell me how to disable the RefreshButton in Browser toolbar , F5 and RightClick in the IE and FireFox browsers by using javaScript Functions Please tell me how to...
1
by: sambati | last post by:
Hi Guys, I want to execute script function for the following conditions , 1. when user press Alt+F4 key 2. from taskbar->rightclick-> close the browser option. But My html...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.