PDA

View Full Version : How can I make the Sticky Note Script a function?



stevenclary
11-09-2005, 07:41 PM
The script in question is:
http://www.dynamicdrive.com/dynamicindex17/stickynote.htm

As it is currently written, the script seems to happen everytime the page loads (at the DIV tag).

Instead of the script running everytime on the page, I would like to know if there is anyway that I can make this script work only when called (maybe from a <a href="javascript.runStickNoteScriptFunction()">. For example, if a particular link on the page is clicked, the user then sees the stick note.

Steve Clary

ddadmin
11-09-2005, 08:09 PM
Sure, simply comment this block of code inside the script:


/*
if (displaymode=="oncepersession" && get_cookie("fadedin")=="" || displaymode=="always" || parseInt(displaymode)!=NaN && random_num==0){
if (window.addEventListener)
window.addEventListener("load", initfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", initfunction)
else if (document.getElementById)
window.onload=initfunction
document.cookie="fadedin=yes"
}
*/

Then, inside your HTML, use a link like this to activate the note:


<a href="javascript:initfunction()">Show sticky</a>

stevenclary
11-09-2005, 09:09 PM
Great!
I'm not familiar with DIV tags. I get feeling that the DIV tag (with the fadeinbox ID) is controlling the sticky note somehow. Am I bypassing any of that with this function effort?

Can I still incorporate the funtionality from the DIV tags?
Seems like the "Sticky Note" has a different size when I call it on my own.



<div id="fadeinbox" style="filter:progid:DXImageTransform.Microsoft.RandomDissolve(duration=1) progid:DXImageTransform.Microsoft.Shadow(color=gray,direction=135) ; -moz-opacity:0">

Also, what should I do with the
<div align="right"><a href="#" onClick="hidefadebox();return false">Close</a></div>

Do these tags still need to be in the page somewhere?

Steve

ddadmin
11-09-2005, 09:26 PM
The DIV tag is where your Sticky Content is contained inside, but the code changes I posted above don't touch this part, so I'm not 100% certain your question/ delima?