Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<a href> and disable right click -Thanks

Status
Not open for further replies.

sd110404

Programmer
Nov 3, 2004
63
US
Hi ,
I have two questions:

1) I have a link (<a href...>) on my page for eg:

when i type this on my browser (below url for example)
I am displaying a link say "Hardness" (which is a link).

On click of that link (hardness) I use window.open (to open a small window).
So my <a href...> looks like this:

<a href="#" onclick=window.open(....)>Hardness</a>

Everything works fine, except that when i click on Hardness the parent page refreshes to and loose the existing information.

Does anyone help me with this. I belive i am clear in explaining the above issue.

2) My second question:
How do i disable right click on window.open? Is that possible? I am opening an image file in window.open.
eg: window.open('image/image.gif', ....)
Thanks.
 
Whatever you do to disable the right click button can be overcome. This is a question that gets asked here and in the Javascript forum a LOT, and the basic answer is don't bother. It's something that is generally attributed to websites done by amateurs, not professionals. Even if you CAN discourage some people from grabbing the photo, it's already on their computer in the temporary internet files, and they can get the URL with the View Source button, and access the photo directly.

Lee
 
I guess this IS the Javascript forum. Had a window open in the HMTL forum and thought I was answering the question there.

Lee
 
How do i change this thread to HTML forum.
 
Your questions are appropriate for the Javascript forum, it's just that the one about disabling the right click function has been thrashed to death already.

As for your other one, you can use:

Code:
<script language="javascript">
function openwindow(pictureurl)
{
window.open(pictureurl,'','');
}
</script>
<a href="javascript:openwindow('picturename.jpg')">Hardness</a>

Lee
 
Thanks a lot Lee or your time. I tried the above code and it works. Actually i was trying the below :)

<a href="javascript:window.open(....)">Hardness</a>

Thanks for your help.

 
Putting the call directly into the <a href> will often cause the page to reload with a blank screen. By creating your own Javascript function and calling that, the page doesn't change. This is a problem with ANY built in JS object methods (functions), and I recommend creating your own function because of that. As well, having a single function to call means if you want to change the code a bit, it takes care of every place on the page where you call the function, rather than having to make sure you find each one.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top