|
Hi,
Please verify item object which is set or not like set the debug point on following line
item.setTemplate(template);
and see whether item has any value if not then the problem is in following line
var item = $('#' + newID);
Thanks
sunaSaRa Imdadhusen
+91 99095 44184
+91 02767 284464
|
|
|
|
|
what is the best way to protect your javascript IP from being snatched and used without your permission? do you obfuscate, encrypt/decrypt your client side javascript?
thanks!
----------------------------------------------------------
Lorem ipsum dolor sit amet.
|
|
|
|
|
Obfuscate the client side scripting.
Here is an example site for doing just that;
http://www.javascriptobfuscator.com/[^]
I ran some code through and here is the example input and output;
function save_options() {
var currentID = localStorage["memberID"];
var newID = textMemberID.value;
if (!(currentID == newID)) {
localStorage["memberID"] = newID;
if (localStorage["memberID"] == newID) {
save_status.innerHTML = "MemberID: " + localStorage["memberID"] + " saved to local storage.";
setTimeout(function () { save_status.innerHTML = ""; }, 1000);
var newRep = new Array();
for (i = 0; i < 9; i++) {
newRep[i] = "0";
}
setNewRepDetail(newRep);
clearTable();
reload_Page();
}
else
{ save_status.innerHTML = "Error saving MemberID to localStorage."; }
}
else {
save_status.innerHTML = "MemberID: has not changed.";
setTimeout(function () { save_status.innerHTML = ""; }, 1000);
}
}
Output;
var _0x9c0d=["\x6D\x65\x6D\x62\x65\x72\x49\x44","\x76\x61\x6C\x75\x65","\x69\x6E\x6E\x65\x72\x48\x54\x4D\x4C","\x4D\x65\x6D\x62\x65\x72\x49\x44\x3A\x20","\x20\x73\x61\x76\x65\x64\x20\x74\x6F\x20\x6C\x6F\x63\x61\x6C\x20\x73\x74\x6F\x72\x61\x67\x65\x2E","","\x30","\x45\x72\x72\x6F\x72\x20\x73\x61\x76\x69\x6E\x67\x20\x4D\x65\x6D\x62\x65\x72\x49\x44\x20\x74\x6F\x20\x6C\x6F\x63\x61\x6C\x53\x74\x6F\x72\x61\x67\x65\x2E","\x4D\x65\x6D\x62\x65\x72\x49\x44\x3A\x20\x68\x61\x73\x20\x6E\x6F\x74\x20\x63\x68\x61\x6E\x67\x65\x64\x2E"];function save_options(){var _0xa035x2=localStorage[_0x9c0d[0]];var _0xa035x3=textMemberID[_0x9c0d[1]];if(!(_0xa035x2==_0xa035x3)){localStorage[_0x9c0d[0]]=_0xa035x3;if(localStorage[_0x9c0d[0]]==_0xa035x3){save_status[_0x9c0d[2]]=_0x9c0d[3]+localStorage[_0x9c0d[0]]+_0x9c0d[4];setTimeout(function (){save_status[_0x9c0d[2]]=_0x9c0d[5];} ,1000);var _0xa035x4= new Array();for(i=0;i<9;i++){_0xa035x4[i]=_0x9c0d[6];} ;setNewRepDetail(_0xa035x4);clearTable();reload_Page();} else {save_status[_0x9c0d[2]]=_0x9c0d[7];} ;} else {save_status[_0x9c0d[2]]=_0x9c0d[8];setTimeout(function (){save_status[_0x9c0d[2]]=_0x9c0d[5];} ,1000);} ;} ;
|
|
|
|
|
Yeah - and anyone can go to sites such as this[^] , or google elsewhere, and de-obfuscate it again.
It might be good for compression purposes, but you'd be an idiot to try hiding aything really imprtant in it, and a fool if you think your IP will be protected because of it.
Short answer tot eh OP's question is: you can't, so don't bother. The longer one is: why do you want to, really? Is there anything in your code that is so mind-blowing, and hasn't been done before, that you just have to stop anyone else from seeing it? Or learning from it...
|
|
|
|
|
Obfuscation is only good for deterring the casual code browser. I totally accept that.
|
|
|
|
|
Here is the code....it works fine on mozilla but on IE clearInterval doesn't work,,...
<br />
<html><br />
<head><br />
<style type="text/css"><br />
.imgf{width:300px; height:250px;}<br />
#img2{z-index:1000;}<br />
</style><br />
<script language="javascript"><br />
window.onload=inItAll;<br />
var j=0;<br />
var N=2;<br />
function inItAll()<br />
{<br />
document.getElementById("img1").onclick=click;<br />
}<br />
<br />
function click()<br />
{<br />
if(navigator.appName=="Netscape")<br />
{<br />
j=0.9;<br />
setInterval("fadeN()",40);<br />
<br />
}<br />
else<br />
{<br />
j=90;<br />
var fI = setInterval("fadeI()",40);<br />
}<br />
<br />
}<br />
<br />
function fadeN()<br />
{<br />
j=j-0.1<br />
<br />
if(j>0.4)<br />
{ <br />
<br />
document.getElementById("img1").style.opacity= j;<br />
}<br />
else<br />
{<br />
j=0.4;<br />
window.clearInterval();<br />
<br />
document.getElementById("img1").src = "images/"+2+".jpg";<br />
<br />
setInterval("showN()",40);<br />
<br />
} <br />
<br />
}<br />
<br />
function showN()<br />
{<br />
<br />
if(j<1)<br />
{<br />
document.getElementById("img1").style.opacity= j;<br />
j=0.1 + j;<br />
<br />
}<br />
else<br />
{<br />
window.clearInterval();<br />
document.getElementById("img1").style.opacity= 1;<br />
<br />
}<br />
}<br />
<br />
function fadeI()<br />
{<br />
j=j-10<br />
<br />
if(j>40)<br />
{ <br />
document.getElementById("img1").style.filter ="alpha(opacity="+j+")";<br />
<br />
}<br />
else<br />
{<br />
j=40;<br />
window.clearInterval(fI);<br />
<br />
document.getElementById("img1").src = "images/2.jpg";<br />
<br />
var sI = setInterval("showI()",40);<br />
} <br />
<br />
}<br />
<br />
function showI()<br />
{<br />
<br />
if(j<100)<br />
{<br />
document.getElementById("img1").style.filter ="alpha(opacity="+j+")";<br />
j=10 + j;<br />
<br />
}<br />
else<br />
{<br />
document.getElementById("img1").style.filter ="alpha(opacity="+100+")";<br />
window.clearInterval(sI);<br />
<br />
}<br />
}<br />
<br />
</script><br />
</head><br />
<body><br />
<center><br />
<br/><br />
<br/><br />
<div id="div1"><br />
<img src="images/1.jpg" class="imgf" id="img1"/><br />
</div> <br />
</center><br />
</body><br />
</html><br />
it gives unwanted flicks on IE coz clearInterval did not work.....
|
|
|
|
|
Try using JQuery[^]. Cross platform and much less to write.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I don't know anything about jquery......it's will take long to understand and implement that coz it's new technology for me...so plz can u help me with this in Javascript code....
Thnx...
|
|
|
|
|
Mmmm... did you even try to click on the link Mark provided ? Because I'm not sure anyone is gonna help you here if, on your side, you're not able to give yourself a little effort.
|
|
|
|
|
<script src=jquery-1.4.2.min.js />
$("#img1).fadeIn();
This is too difficult for you?
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
I used JQuery and JQueryUI in my last article, it was the first time i had even looked at JQuery, let alone actual go an implement it.
You should find it no problem at all, the basics are surprisingly simple.
|
|
|
|
|
EDIT:
OOps, sorry Mark, replied to the wrong message!
ignore it.
|
|
|
|
|
When you use setInterval you are supposed to set it to a variable, which becomes its ID, in effect - eg
instead of just writing
setInterval("showN()",40);
as you have, you should write
var IntervalID = setInterval("showN()",40);
Then, later when you want to clear it, you must refer to that ID:
clearInterval(intervalID);
Edit: screw jQuery. Never found a use for it yet. DIY, always.
|
|
|
|
|
NeverHeardOfMe wrote: screw jQuery. Never found a use for it yet. DIY, always.
That's what we need, more people who refuse to learn and espouse the "always been done that way" dictum.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Not at all - my "objection" to the likes of jQuery is precicely that it *stops* one from learning - it's just a box of magic tricks and turns you into a dancing dog. I prefer to try and learn how to do things myself.
Of course the reducto ad absurdum of this argument is that we should all go back to coding in machine language, and I am aware of that and the sillines of re-inventing the wheel. Nevertheless, I do feel there is a certian merit to my position - how often do we see questions asked here from people who have clearly learned a few "tricks" but have absolutely no real understanding of what they asking about?
|
|
|
|
|
JQuery is not a black box, you have the full source code available to actually research and learn. With .NET Reflector I'm often looking at Microsoft's code to see how something was done and learning.
You're argument is a bit weak but not worth the effort to drag out.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
 I modified da code and put var ID... = setInterval(....)...,
but now it says da ID i gave is unidentified by browsers(both IE and Firefox).....
<br />
window.onload=inItAll;<br />
var j=0;<br />
var N=2;<br />
function inItAll()<br />
{<br />
document.getElementById("img1").onclick=click;<br />
}<br />
<br />
<br />
function click()<br />
{ <br />
<br />
if(navigator.appName=="Netscape")<br />
{<br />
j=0.9;<br />
<br />
var IntervalIDN1 = setInterval("fadeN()",40);
<br />
<br />
}<br />
else<br />
{<br />
j=90;<br />
var IntervalIDI1 = setInterval("fadeI()",40);
}<br />
<br />
}<br />
<br />
function fadeN()
{<br />
j=j-0.1<br />
<br />
if(j>0.4)<br />
{ <br />
<br />
document.getElementById("img1").style.opacity= j;<br />
}<br />
else<br />
{<br />
j=0.4;<br />
window.clearInterval(IntervalIDN1);<br />
<br />
document.getElementById("img1").src = "images/"+N+".jpg";<br />
<br />
var IntervalIDN2 = setInterval("showN()",40);<br />
<br />
} <br />
<br />
}<br />
<br />
function showN()
{<br />
<br />
if(j<1)<br />
{<br />
document.getElementById("img1").style.opacity= j;<br />
j=0.1 + j;<br />
<br />
}<br />
else<br />
{<br />
window.clearInterval(IntervalIDN2);<br />
document.getElementById("img1").style.opacity= 1;<br />
<br />
}<br />
}<br />
<br />
function fadeI()
{<br />
j=j-10<br />
<br />
if(j>40)<br />
{ <br />
document.getElementById("img1").style.filter ="alpha(opacity="+j+")";<br />
<br />
}<br />
else<br />
{<br />
j=40;<br />
window.clearInterval(IntervalIDI1);<br />
<br />
document.getElementById("img1").src = "images/2.jpg";<br />
<br />
var IntervalIDI2 = setInterval("showI()",40);<br />
} <br />
<br />
}<br />
<br />
function showI()
{<br />
<br />
if(j<100)<br />
{<br />
document.getElementById("img1").style.filter ="alpha(opacity="+j+")";<br />
j=10 + j;<br />
<br />
}<br />
else<br />
{<br />
document.getElementById("img1").style.filter ="alpha(opacity="+100+")";<br />
window.clearInterval(IntervalIDI2);<br />
<br />
}<br />
}<br />
if i remove ids it works perfectly on Firefox but not on IE....
|
|
|
|
|
well you need to define the var IntervalID outside of the functions (so that it is globally accessible to all), and then justs et it within
var IntervalID;
...
function XYZ () {
IntervalID = ...
}
|
|
|
|
|
|
i was creating little animation using javascript....but got stuck
<br />
<html><br />
<head><br />
<style type="text/css"><br />
body{}<br />
.imgC{width:350px; height:300px;}<br />
#divV{background-color:#000000; opacity:0.6; filter:alpha(opacity=60);<br />
width:350px; height:70px;}<br />
#mainDiv{width:100%; height:100%; background-color:#c3c3c3; top:0px; left:0px;<br />
position:absolute;} <br />
</style><br />
<script language="javascript"><br />
window.onload=inItAll;<br />
<br />
function inItAll()<br />
{<br />
document.getElementById("img1").onmouseover = cursorOver;<br />
document.getElementById("img1").onmouseout = cursorOut;<br />
document.getElementById("divV").onmouseout = cursorVOut;<br />
<br />
<br />
}<br />
<br />
function cursorOver()<br />
{<br />
<br />
if(!document.getElementById("divV"))<br />
{<br />
var Y1 = document.getElementById("img1").offsetTop;<br />
var X1 = document.getElementById("img1").offsetLeft;<br />
var Elem = document.createElement("div");<br />
Elem.id="divV";<br />
Elem.cssClass="divVc";<br />
Elem.style.position="absolute";<br />
Elem.style.top = 230+Y1+"px";<br />
Elem.style.left = X1+"px";<br />
document.getElementById("div1").appendChild(Elem);<br />
}<br />
}<br />
<br />
function cursorOut(e)<br />
{<br />
var Y1 = document.getElementById("img1").offsetTop;<br />
var Y2 = Y1 + 300;<br />
var X1 = document.getElementById("img1").offsetLeft;<br />
var X2 = X1 + 350;<br />
if (!e)<br />
var e = window.event;<br />
<br />
if (e.pageX || e.pageY) {<br />
posx = e.pageX;<br />
posy = e.pageY;<br />
<br />
}<br />
else if (e.clientX || e.clientY) {<br />
posx = e.clientX <br />
posy = e.clientY <br />
}<br />
<br />
if(posx>=X1 && posx<=X2 && posy>=Y1 && posy<=Y2)<br />
{<br />
<br />
<br />
}<br />
else<br />
{<br />
<br />
var Elem = document.getElementById("divV");<br />
document.getElementById("div1").removeChild(Elem);<br />
<br />
<br />
<br />
}<br />
<br />
}<br />
<br />
function cursorVOut()<br />
{<br />
<br />
var Elem = document.getElementById("divV");<br />
document.getElementById("div1").removeChild(Elem);<br />
<br />
}<br />
<br />
</script><br />
</head><br />
<body><br />
<div id="mainDiv"><br />
<div id="div1"><br />
<center><br />
<img src="images/1.jpg" id="img1" class="imgC"/><br />
</center><br />
</div><br />
</div><br />
<br />
</body><br />
</html> <br />
everything works fine except document.getElementById("divV").onmouseout = cursorVOut;
this part is not working.....
when i bring cursor on image(img1) a small div appears at the bottom of image and if i move my cursor out it should disappear...the problem is when i move my cursor away frm divV to mainDiv event doesn,t work......
|
|
|
|
|
Personally I can't see how any of it works. Your onload function refers to divV before it has even been defined.
Can I suggest you try using the Error console in Firefox to try debugging your JavaScript....
|
|
|
|
|
Hi,
I have below code to open pop-under window.but it blocked by the browser.
please tell me how can unblock a pop-under using java script.
<SCRIPT LANGUAGE='JAVASCRIPT' TYPE='TEXT/JAVASCRIPT'>
function openwin()
{
window.open("http://www.yahoo.com");
}
</script>
<body onLoad="openwin();">
|
|
|
|
|
jasimmd wrote: please tell me how can unblock a pop-under using java script.
At the browser level, people block things for any number of reason. Why do you want to usurp the people's privileges and rights?
modified 1-Aug-19 21:02pm.
|
|
|
|
|
Pop ups are generally allowed by blockers as long as the popup was initiated by a user action. Therefore, the answer to your question is to allow the user to click a button/link tto open the popup, and not to do it onload (which is a favourite trick of the popup advertiser - hence why they're blocked).
If you could disable this using javascript, it would negate the usefullness of popup blockers in the first place.
|
|
|
|
|
I want to provide sitemap with scrolling of images. I'm handling the method for scrolling image as in "Text and Image Crawler" of Dynamicdrive.com (http://www.dynamicdrive.com/dynamicindex2/crawler/index.htm). I've just changed the images and added a click event for images. The crawler.js is the same as in the "Text and Image Crawler" of Dynamicdrive.com.
In my application thing is for services, there is submenus. When the services image is clicked.. the marque movement should be paused until other than services (home, about_us, careers, contact_us) is clicked and the images of the submenu should get displayed. When other than services is clicked, the display of the submenu images must be in hide condition. IS it possible to do so. If so guide and help me.
Currently, I'd hide the submenu images by setting the property 'display:none;' for the div-id in styles.css. And when clicked i've coded to display the submenu images with javascript. But not working.
My html code is:
*****************
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta name="GENERATOR" content="Microsoft FrontPage 6.0" />
<meta name="ProgId" content="FrontPage.Editor.Document" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<title>My Project</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="js/scroll-image.js"></script>
<script type="text/javascript" src="js/crawler.js"></script>
<!-- [if gte IE 7]><!-->
<link type="text/css" rel="stylesheet" href="css/style-ie6.css" />
<!--<![endif]-->
</head>
<body style="line-height: 150%">
<div>
<div style=" background:#E3E1E2; width: 766px; margin: 0px auto">
<p class="body_text_heading" align=left><br> <br> Sitemap<br> <br> <br> <br> </p>
<div style=" background:#E3E1E2; width: 730px; margin: 0px auto;">
<div class="marquee" id="image_scroll">
<img src="images/site_home.jpg" width="300" height="300" alt="Home" id="1_img" onclick="scrollimage('home');";/>
<img src="images/site_about_us.jpg" width="300" height="300" alt="About Us" id="2_img" onclick="scrollimage('about_us');"/>
<img src="images/site_careers.jpg" width="300" height="300" alt="Careers" id="3_img" onclick="scrollimage('careers');"/>
<img src="images/site_services.jpg" width="300" height="300" alt="Services" id="4_img" onclick="scrollimage('services');"/>
<img src="images/site_contact_us.jpg" width="300" height="300" alt="Contact Us" id="5_img" onclick="scrollimage('contact_us');"/>
</div>
<p class="body_text_heading" align=left><br> <br> <br> </p>
<script type="text/javascript">
marqueeInit({
uniqueid: 'image_scroll',
style: {
'padding': '2px',
'width': '700px',
'height': '300px'
},
inc: 5,
mouse: 'cursor driven',
direction: 'left',
noAddedSpace: false,
stopped: false,
moveatleast: 4,
neutral: 150,
savedirection: 'true'
});
</script>
<div id="subScroll">
<div class="marquee" id="image_scroll_sub">
<img src="images/site_knowledge.jpg" width="300" height="300" alt="Knowledge Transfer" id="6_img" onclick="scrollimage('knowledge');";/>
<img src="images/site_business_consultancy.jpg" width="300" height="300" alt="About Us" id="7_img" onclick="scrollimage('business_consultancy');"/>
<img src="images/site_hrd.jpg" width="300" height="300" alt="Careers" id="8_img" onclick="scrollimage('hrd');"/>
<img src="images/site_carbon_credits.jpg" width="300" height="300" alt="Services" id="9_img" onclick="scrollimage('carbon_credits');"/>
<img src="images/site_hedge.jpg" width="300" height="300" alt="Contact Us" id="10_img" onclick="scrollimage('hedge');"/>
</div>
<p class="body_text_heading" align=left><br> <br> <br> </p>
<script type="text/javascript">
marqueeInit({
uniqueid: 'image_scroll_sub',
style: {
'padding': '5px',
'width': '500px',
'height': '300px'
},
inc: 5,
mouse: 'cursor driven',
direction: 'right',
noAddedSpace: false,
stopped: false,
moveatleast: 4,
neutral: 150,
savedirection: 'true'
});
</script>
</div>
</div>
</div>
</div>
</body>
</html>
Scrollimage function within scroll-image.js
*******************************************
function scrollimage(getDirection){
initScroll();
if(getDirection=='home')
{
document.getElementById('subScroll').style.display='none';
alert("home");
}
if(getDirection=='about_us')
{
document.getElementById('subScroll').style.display='none';
alert("about_us");
}
if(getDirection=='careers')
{
document.getElementById('subScroll').style.display='none';
alert("careers");
}
if(getDirection=='services')
{
document.getElementById('subScroll').style.position='relative';
document.getElementById('subScroll').style.display='inline';
alert("services");
}
if(getDirection=='contact_us')
{
document.getElementById('subScroll').style.display='none';
alert("contact_us");
}
if(getDirection=='knowledge')
{
document.getElementById('subScroll').style.display='inline';
alert("knowledge");
}
if(getDirection=='business_consultancy')
{
document.getElementById('subScroll').style.display='inline';
alert("business_consultancy");
}
if(getDirection=='hrd')
{
document.getElementById('subScroll').style.display='inline';
alert("hrd");
}
if(getDirection=='carbon_credits')
{
document.getElementById('subScroll').style.display='inline';
alert("carbon_credits");
}
if(getDirection=='hedge')
{
document.getElementById('subScroll').style.display='inline';
alert("hedge");
}
function initScroll()
{
document.getElementById('subScroll').style.display='none';
}
}
Content of div-id(subScroll) in style.css
*****************************************
#subScroll
{
display:none;
}
M.Sworna Vidhya
|
|
|
|