OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



[Ask-asap]Disable right click / Disable copy-paste?

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

[Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Tue Dec 01, 2009 5:32 am

Hello,this is my first post :)
okay, let's to the point... :P

I want to protect the articles from copy-paste(in: /article/view/*)
for example like in this website:
Code: Select all
http://www.metrolyrics.com/little-wonders-lyrics-rob-thomas.html

when i see the source code,this website using javasricpt to disable the copy-paste(is it right :?: )

can i use "javascript" to protect the journal content from copy-paste?
or...
do you have another suggestion?

your help will be appreciated :o
sorry for my poor english :oops:

Thanks before :D
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Wed Dec 02, 2009 7:10 am

Any one can help?

i search in google and find this:
Disable Text Selection script
This is a simple script that lets you disable text selection (the ability to drag and select text) within any element on your page, such as a certain paragraph. Script works in IE, Firefox, and Opera.


Directions: Add this script to the HEAD section of your page:
Code: Select all
<script type="text/javascript">

/***********************************************
* Disable Text Selection script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

function disableSelection(target){
if (typeof target.onselectstart!="undefined") //IE route
   target.onselectstart=function(){return false}
else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
   target.style.MozUserSelect="none"
else //All other route (ie: Opera)
   target.onmousedown=function(){return false}
target.style.cursor = "default"
}

//Sample usages
//disableSelection(document.body) //Disable text selection on entire body
//disableSelection(document.getElementById("mydiv")) //Disable text selection on element with id="mydiv"

</script>


With the script installed, just call the function disableSelection(target) at the very end of the document with a reference to the element you wish to disable text within. A few examples:


Code: Select all
<script type="text/javascript">
disableSelection(document.body) //disable text selection on entire body of page
</script>

Code: Select all
<script type="text/javascript">
var somediv=document.getElementById("mydiv")
disableSelection(somediv) //disable text selection within DIV with id="mydiv"
</script>

Code: Select all
<script type="text/javascript">
var alltables=document.getElementsByTagName("table")
for (var i=0; i<alltables.length; i++)
disableSelection(alltables[i]) //disable text selection within all tables on the page
</script>

Make sure to call the above functions at the end of the document to ensure the element in which to disable text for is defined before the function is called.


but i confuse how to implent in OJS :|
where i must store the source-code?(in Article.tpl / View.tpl or where?)

your help will be appreciated :D

thanks before
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby mcrider » Wed Dec 02, 2009 11:03 am

Hi nekomochi,

If you want to implement this in the reading tools for each article, put the function declaration in templates/rt/header.tpl and the calls to the function in templates/rt/footer.tpl files. Or you can enable it site-wide by putting the code in templates/common/header.tpl and templates/common/footer.tpl.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Wed Dec 02, 2009 8:14 pm

thanks for the reply :)

I've tried it, but it seems to have succeeded :(
here I put my source code...
templates/rt/header.tpl
Code: Select all
{**
 * header.tpl
 *
 * Copyright (c) 2003-2009 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * Common header for RT pages.
 *
 * $Id: header.tpl,v 1.27 2009/07/03 16:56:32 asmecher Exp $
 *}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<script type="text/javascript">
   function disableSelection(target){
      if (typeof target.onselectstart!="undefined") //IE route
   target.onselectstart=function(){return false}
      else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
   target.style.MozUserSelect="none"
      else //All other route (ie: Opera)
   target.onmousedown=function(){return false}
   target.style.cursor = "default"
   }
</script>

<head>
   <title>{translate key="rt.readingTools"}</title>
   <meta http-equiv="Content-Type" content="text/html; charset={$defaultCharset|escape}" />
   <meta name="description" content="" />
   <meta name="keywords" content="" />

   <link rel="stylesheet" href="{$baseUrl}/lib/pkp/styles/common.css" type="text/css" />
   <link rel="stylesheet" href="{$baseUrl}/styles/common.css" type="text/css" />
   <link rel="stylesheet" href="{$baseUrl}/lib/pkp/styles/rt.css" type="text/css" />

   {foreach from=$stylesheets item=cssUrl}
      <link rel="stylesheet" href="{$cssUrl}" type="text/css" />
   {/foreach}

   <script type="text/javascript" src="{$baseUrl}/lib/pkp/js/general.js"></script>
   {$additionalHeadData}
</head>
<body>
{literal}
<script type="text/javascript">
<!--
   if (self.blur) { self.focus(); }
// -->
</script>
{/literal}

{if !$pageTitleTranslated}{translate|assign:"pageTitleTranslated" key=$pageTitle}{/if}

<div id="container">

<div id="header">
<div id="headerTitle">
<h1>{if $currentJournal && $currentJournal->getLocalizedInitials()}{$currentJournal->getLocalizedInitials()}&nbsp;{/if}{translate key="rt.readingTools"}</h1>
</div>
</div>

<div id="body">
<div id="top"></div>

<div id="main">

{literal}
<script type="text/javascript">
<!--
   if (self.blur) { self.focus(); }
// -->
</script>
{/literal}

<h2>{$pageTitleTranslated}</h2>

<div id="content">


and i put the "call function" in here
templates/rt/footer.tpl
Code: Select all
<script type="text/javascript">
disableSelection(document.body)
</script>

{**
 * footer.tpl
 *
 * Copyright (c) 2003-2009 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * Common footer for RT pages.
 *
 * $Id: footer.tpl,v 1.14 2009/04/08 19:54:52 asmecher Exp $
 *}
<br />

{if !$omitCloseButton}
<input type="button" onclick="window.close()" value="{translate key="common.close"}" class="button defaultButton" />
{/if}

{call_hook name="Templates::Rt::Footer::PageFooter"}
</div>
</div>
</div>
</div>
</body>
</html>


but it still don't work :?
any idea?, or some source-code i put is wrong?


thanks before :)
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby mcrider » Thu Dec 03, 2009 11:15 am

Hi nekomochi,

You have to put the header code after the <head> tag, and also you should the footer code right before the </body> tag. Try that out and let us know how it goes.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Fri Dec 04, 2009 5:13 pm

Hi:D
i have been try it, and still don't work :( :?:

hmm i think the source code must be placed in other .tpl files...
why not put the source code in (\templates\article\article.tpl) because that's mentioned files have a responsible for showing the article to public?...

while RT folders is just for show Reading tools(in sidebar)... :?

thanks before... :)
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Sun Dec 06, 2009 7:49 am

anyone can help? :(
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby mcrider » Sun Dec 06, 2009 4:00 pm

Hi nekomochi,

Are your articles in HTML or are they PDFs? Whatever javascript you use, it won't be applied to PDFs if that's the case. Otherwise, I'd suggest using a javascript debugging tool like FireBug for FireFox to make sure that your script is being loaded properly and is bug-free.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Sun Dec 06, 2009 6:06 pm

articles show in HTML format as usual ...
approximately like the following picture:
Image

thanks before :)
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby mcrider » Mon Dec 07, 2009 11:28 am

Hi nekomochi,

Try putting the code in the templates/article/view.tpl file instead.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Tue Dec 08, 2009 8:19 am

hello :D
I've tried to putting the code in the "templates/article/view.tpl"

but still not working ...
This is my source code, if there is something wrong?
Code: Select all
{**
 * view.tpl
 *
 * Copyright (c) 2003-2009 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * Article View.
 *
 * $Id: view.tpl,v 1.33 2009/06/02 21:20:58 asmecher Exp $
 *}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
   <meta http-equiv="Content-Type" content="text/html; charset={$defaultCharset|escape}" />
   <title>{$article->getFirstAuthor(true)|escape}</title>

   <link rel="stylesheet" href="{$baseUrl}/lib/pkp/styles/common.css" type="text/css" />
   <link rel="stylesheet" href="{$baseUrl}/styles/common.css" type="text/css" />
   <link rel="stylesheet" href="{$baseUrl}/styles/articleView.css" type="text/css" />

   {foreach from=$stylesheets item=cssUrl}
      <link rel="stylesheet" href="{$cssUrl}" type="text/css" />
   {/foreach}

   <script type="text/javascript" src="{$baseUrl}/lib/pkp/js/general.js"></script>
   <script type="text/javascript" src="{$baseUrl}/lib/pkp/js/disable.js"></script>
   {$additionalHeadData}
</head>
<frameset cols="*,180" style="border: 0;">
   {if !$galley}
      {url|assign:"articleUrl" op="viewArticle" path=$articleId}
      {url|assign:"rstUrl" op="viewRST" path=$articleId}
   {else}
      {url|assign:"rstUrl" op="viewRST" path=$articleId|to_array:$galleyId}
      {if $galley->isHtmlGalley()}
         {url|assign:"articleUrl" op="viewArticle" path=$articleId|to_array:$galleyId}
      {elseif $galley->isPdfGalley()}
         {url|assign:"articleUrl" op="viewPDFInterstitial" path=$articleId|to_array:$galleyId}
      {elseif $galley->isInlineable()}
         {url|assign:"articleUrl" op="viewFile" path=$articleId|to_array:$galleyId}
      {else}
         {url|assign:"articleUrl" op="viewDownloadInterstitial" path=$articleId|to_array:$galleyId}
      {/if}
   {/if}
   <frame src="{$articleUrl}" frameborder="0"/>
   <frame src="{$rstUrl}" noresize="noresize" frameborder="0" scrolling="auto" />
<noframes>
<body>
   <table width="100%">
      <tr>
         <td align="center">   
            {translate key="common.error.framesRequired" url=$articleUrl}
         </td>
      </tr>
   </table>   
</body>
</noframes>
</frameset>
</html>
<script type="text/javascript">
disableSelection(document.body)
</script>
<script type="text/javascript">
var somediv=document.getElementById("articleAbstract")
disableSelection(somediv)
</script>
<script type="text/javascript">
var alltables=document.getElementsByTagName("table")
for (var i=0; i<alltables.length; i++)
disableSelection(alltables[i])
</script>

*I make files "disable.js":
where this script, will be called in this function "<script type="text/javascript" src="{$baseUrl}/lib/pkp/js/disable.js"></script>"

I also have to check with Firebug:
Code: Select all
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
<title>Widodo</title>
<link type="text/css" href="http://localhost/ejournals/lib/pkp/styles/common.css" rel="stylesheet">
</link>
<link type="text/css" href="http://localhost/ejournals/styles/common.css" rel="stylesheet">
</link>
<link type="text/css" href="http://localhost/ejournals/styles/articleView.css" rel="stylesheet">
</link>
<link type="text/css" href="http://localhost/ejournals/plugins/themes/uncommon/uncommon.css" rel="stylesheet">
</link>
<script src="http://localhost/ejournals/lib/pkp/js/general.js" type="text/javascript">
</script>
<script src="http://localhost/ejournals/lib/pkp/js/disable.js" type="text/javascript">
</script>
<script src="http://localhost/ejournals/lib/pkp/js/sizer.js" type="text/javascript">
</script>
<link type="text/css" href="http://localhost/ejournals/styles/fontSmall.css" title="Small" rel="alternate stylesheet"/>
<link type="text/css" href="http://localhost/ejournals/styles/fontMedium.css" title="Medium" rel="stylesheet">
</link>
<link type="text/css" href="http://localhost/ejournals/styles/fontLarge.css" title="Large" rel="alternate stylesheet"/>

<script type="text/javascript">
disableSelection(document.body)
</script>

<script type="text/javascript">
var somediv=document.getElementById("articleAbstract")
disableSelection(somediv)
</script>

it looks like the code is run correctly, but why Javascript Protection still not working ?

thanks before :)
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Tue Dec 08, 2009 5:34 pm

anyone can help?
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby mcrider » Wed Dec 09, 2009 5:18 pm

Hi nekomochi,

Are you getting any errors in your javascript console in firebug? Sometimes you have to put function calls disableSelection() at the bottom of the page--Try putting it before the </html> tag or else experiment by putting it in a few other parts of the page.

Cheers,
Matt
mcrider
 
Posts: 952
Joined: Mon May 05, 2008 10:29 am
Location: Vancouver, BC

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Sat Dec 12, 2009 8:37 am

thanks for the reply
I've tried it and could go well:)

I want to ask again:
Can we look at OJS "View" (/ article / view /) by using the display PDF format directly(from browser)?
more or less it looks like the "Gooogledocs", where we can see PDF / DOC files more quickly..?(without download the file..)

Example of Google Docs:
http://docs.google.com/viewer?a=v&q=cache:cziYvf7TNEgJ:iwan.or.id/cetak/pdf/248/Delphi_Tutorial_1.0.pdf+delphi+tutorial&hl=id&gl=id&pid=bl&srcid=ADGEESiOY41lKJe7Kn_Ie6reTwnvS-tac1nKcKx4hLi9v-MJUPdSZ-S2WZy_8PsO3ARViqZm44V7_ZPsCOtYuifYqE7wPb855Cvk17n5WpiqETE6Wd2BPa5ZZkVQjvtYLBB8Vh1D6gpX&sig=AHIEtbRkczdznsGswIuP0QvO6wEiGxmdrA

thanks before :)
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Re: [Ask-asap]Disable right click / Disable copy-paste?

Postby nekomochi » Sun Dec 13, 2009 5:17 am

I want to ask again:
Can we look at OJS "View" (/ article / view /) by using the display PDF format directly(from browser)?
more or less it looks like the "Gooogledocs", where we can see PDF / DOC files more quickly..?(without download the file..)

Example of Google Docs:
http://docs.google.com/viewer?a=v&q=cac ... 6wEiGxmdrA

thanks before :)


Anyone can help?

Thanks Before :D
nekomochi
 
Posts: 13
Joined: Tue Dec 01, 2009 4:52 am

Next

Return to OJS Development

Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests