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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

No right-click for frame content

Status
Not open for further replies.

harleychick

Programmer
Jun 10, 2002
16
0
0
US
I have a webpage MessageBoard.htm. It contains two frames, a header frame and a main frame. I have a no right-click script in the header section of this page that prevents the user from right-clicking on the header frame. The main frame content MessageDoc.htm is overwritten daily; so, if I add the no right-click script to the header section of the MessageDoc.htm page (source of the main frame), it gets overwritten. How can I add code to the MessageBoard.htm page to prevent users from right-clicking on the main frame content (MessageDoc.htm)?

Thanks in advance,
HarleyChick

Here's the code I have for MessageBoard.htm:
<html>
<head>
<script language="Javascript1.2">
// (C) 2004 CodeLifter.com
//============================================================
//Script: Basic No-Right-Click Script
//Functions: Blocks right-click on mouse but does *not* show
// an alert box or message.
//Browsers: All (4.X and later)
//Author: etLux
//============================================================
//Put the following script in the head of your page:

function nrcIE(){
if (document.all){return false;}}
function nrcNS(e){
if(document.layers||(document.getElementById&&!document.all)){
if (e.which==2||e.which==3){
return false;}}}
if (document.layers){
document.captureEvents(Event.MOUSEDOWN);
document.onmousedown=nrcNS;
}else{document.onmouseup=nrcNS;document.oncontextmenu=nrcIE;}
document.oncontextmenu=new Function("return false");
</script>

<title>Message Board</title>
<base target="_top">
</head>

<frameset rows="16%,*">
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
<frame name="header" scrolling="no" noresize target="main" src="contentheader.asp">
[COLOR=red yellow]<frame name="main" src="bulletin/MessageDoc.htm" target="_self" scrolling="auto">[/color]
</frameset>
</html>
 
HI.
In the body of the page titled bulletin/messagedoc.htm change the body to this:
Code:
<body oncontextmenu="cutBubble()" onselectstart="cutBubble()">

Then in the HEAD section of your page, insert this function:
Code:
function cutBubble()
{
if(event.srcElement.tagName!='INPUT' && event.srcElement.tagName!='IMG')
{
window.event.returnValue=false
}
}

This will allow right click for Images, but not for the web page content.
 
Sorry, in HEAD section, insert the Javascript header, like so:
Code:
<script type="text/javascript">
<!--
function cutBubble()
{
if(event.srcElement.tagName!='INPUT' && event.srcElement.tagName!='IMG')
{
window.event.returnValue=false
}
}

// -->
</script>

Good luck :)
 
That would work if the bulletin/messagedoc.htm file wasn't overwritten. The user creates a filtered html microsoft word document and saves it to the bullten folder as messagedoc.htm daily. I need a way to call the no right-click script from the messageboard.htm page that creates the frames.

<frame name="main" src="bulletin/MessageDoc.htm" target="_self" scrolling="auto" [COLOR=red yellow]oncontextmenu="cutbubble()">[/color]

Would it be parent.cutbubble() or something like that?
 
Very sorry, HarleyChick, I didnt properly read your post :(
I'm honestly not so sure then, did what you list above not work then?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top