There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Software Development
Tag Cloud
audio blue screen boot bsod computer cpu crash dell desktop driver drivers dvd error excel external hard drive firefox format freezes freezing hard drive hardware hijackthis internet internet explorer ipod itunes laptop malware mouse network networking outlook 2007 power printer problem ram router screen slow sound trojan upgrade usb virus vista vista 32-bit windows windows xp winxp wireless
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
creatin link using java script


Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
punjabian263's Avatar
Senior Member with 318 posts.
 
Join Date: Mar 2003
Location: PAKISTAN
Experience: Advanced
01-Jun-2004, 04:50 PM #1
creatin link using java script
hello guys,
how I can restrict a user to access a link e.g
when a user right click on a link a message will pop up, that you are unable to access this link.
Shadow2531's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
02-Jun-2004, 12:16 AM #2
If the user is not allowed to click on the link, it shouldn't be there. You could at least make it hidden (use display: hidden for the element. You can invoke that via css or DOM). Forget about the right-click and middle-click blocking. That won't help. Browsers can be set to not accept right-click and middle-click for javascript rendering those blockers useless.

You could have all links work only if javascript is turned on and for each link call a function that checks a cookie to see if the user is allowed to activate the link. If the user is not, then display an alert box. NOT a very friendly way of doing things though.

This all depends on what specifically, you are trying to do.
__________________
10 ? "a line as the unending horizon"
20 ? "a curve as the rolling hillside"
30 ? "a point as a distant bird"
40 ? "a ray as the rising sun"
run
punjabian263's Avatar
Senior Member with 318 posts.
 
Join Date: Mar 2003
Location: PAKISTAN
Experience: Advanced
02-Jun-2004, 12:24 AM #3
Quote:
If the user is not allowed to click on the link, it shouldn't be there. You could at least make it hidden
Shadow I am talking about, that when a user "right button click"(mouse) on the link, then a dialog box would appear.
Is there a way to do this.
Shadow2531's Avatar
Distinguished Member with 2,629 posts.
 
Join Date: Apr 2001
02-Jun-2004, 01:03 AM #4
Like this, but with right-click?

<a href="http://www.google.com" onclick="alert('Hello')">Click </a>

If so, then you can use this as a basis. However, it will not work for everyone. Specifically Opera users since "allow javascript to accept right-clicks" is turned off by default.

Also remember that tabbed browsing is very popular and middle-click to open in a new tab is used a lot, so you will want to cover the middle-click action too.

It might be better to use a button and just have an onlick event. Right-click and middle click won't work on it.

Or make it look less like a button.

<input style="background-color: #ffffff; border: 1px solid #fff; padding: 5px; margin: 0px;" type="button" value="click me" onclick="alert('Hello');window.location='http://www.google.com'"/>

If you want your own customized right-click menu, it is possible, but it would just be DHMTL.

If you are not looking for that, then a button like this might work.

<input type="button" onclick="alert('Hello');window.location='http://www.google.com'"/>

(Won't be activated by right and middle-click.)

You can also use the onmousedown even for a link. It will capture both left and middle-click; leaving only right-click to be delt with.
__________________
10 ? "a line as the unending horizon"
20 ? "a curve as the rolling hillside"
30 ? "a point as a distant bird"
40 ? "a ray as the rising sun"
run

Last edited by Shadow2531 : 02-Jun-2004 01:55 AM.
punjabian263's Avatar
Senior Member with 318 posts.
 
Join Date: Mar 2003
Location: PAKISTAN
Experience: Advanced
03-Jun-2004, 12:36 AM #5
thanks dear shadow
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who want to help you solve your computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 12:08 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.