472,950 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,950 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 1432
* 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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.