Posted on June 25, 2008 by thekhuc
Yesterday, I had to install Firefox 3, because my most recent work stopped functioning properly in the new Firefox. I wanted to wait a little longer for Firefox 3 to be more stable, but had no other choice. Who would have thought the new version of my beloved Firefox would break my code? Basically, it [...]
Filed under: Browser, Javascript, Work | Tagged: firefox 3, Javascript | No Comments »
Posted on January 9, 2007 by thekhuc
A useful function to interact with Flash movie with Javascript. Works in most browsers. Thanks Permadi.com!
function getFlashMovieObject(movieName)
{
if (window.document[movieName])
{
return window.document[movieName];
}
if (navigator.appName.indexOf(”Microsoft Internet”)==-1)
{
if (document.embeds && document.embeds[movieName])
return document.embeds[movieName];
}
[...]
Filed under: Flash, Javascript, Tutorials and Tricks | 1 Comment »
Posted on January 9, 2007 by thekhuc
A useful Javascript function to return the ID of an element that is supposed to work on most browsers.Thanks Netlobo.com!
function returnObjById( id )
{
if (document.getElementById)
var returnVar = document.getElementById(id);
else if (document.all)
var returnVar [...]
Filed under: Javascript, Tutorials and Tricks | No Comments »
Posted on March 15, 2006 by thekhuc
Suppose I have some text within <div id=”div1″></div> tags, it’s easy to display and hide this block of text with the help of some Javascript code and CSS.
To hide the block of text, do the following:
<script language=”javascript”>
document.getElementById(’div1′).style.display = ‘none’;
</script>
To display the block of text, just remove the word ‘none’ from the code above as follows:
<script [...]
Filed under: CSS, Javascript, Tutorials and Tricks | No Comments »
Posted on February 28, 2006 by thekhuc
The following Javascript code would disable the user from using the browser’s Back button.
<script language=”javascript”>
window.history.forward(1);
</script>
Filed under: Javascript, Tutorials and Tricks | 6 Comments »
Posted on January 16, 2006 by thekhuc
break case continue delete do else false [...]
Filed under: Javascript, Tutorials and Tricks | No Comments »
Posted on December 22, 2005 by thekhuc
var winW = parseInt(”630″), winH = parseInt(”460″);
if (parseInt(navigator.appVersion)>3) {
if (navigator.appName==”Netscape”) {
winW = window.innerWidth;
winH = window.innerHeight;
}
if (navigator.appName.indexOf(”Microsoft”)!=-1) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
}
The above code returns the width and height of the browser window regardless if it’s Netscape or IE. If the browser is Netscape, we use innerWidth and innerHeight properties of the window object to return [...]
Filed under: Javascript, Tutorials and Tricks | No Comments »
Posted on December 21, 2005 by thekhuc
document.onmouseover=GetCoordinates;
function GetCoordinates(e){
if (navigator.appName==”Netscape”) {
xVal = parseInt(e.pageX);
yVal = parseInt(e.pageY);
}
if (navigator.appName.indexOf(”Microsoft”)!=-1) {
xVal=parseInt(event.x);
yVal=parseInt(event.y);
}
}
This line of code document.onmouseover=GetCoordinates; causes the onmouseover to be fired and calls function GetCoordinates, which is used to keep track of every single mouse movement. Also, the appName property of the javascript navigator object is used to identify the user’s browser. If the browser is [...]
Filed under: Javascript, Tutorials and Tricks | No Comments »
Posted on December 20, 2005 by thekhuc
document.onclick=WindowClickEventExplorer;
function WindowClickEventExplorer(e){
if (navigator.appName==”Netscape”) {
popIt=0;
}
if (navigator.appName.indexOf(”Microsoft”)!=-1) {
var WinEvent = window.event.srcElement.tagName;
if (WinEvent ==’INPUT’ || WinEvent ==’IMG’ || WinEvent ==’A’ || WinEvent ==’B’ || WinEvent ==’SELECT’) popIt=0;
}
}
The above code captures all the click events within the document inside the current browser and calls function WindowClickEventExplorer at the mouse click. Inside function WindowClickEventExplorer, appName property of javascript navigator object [...]
Filed under: Javascript, Tutorials and Tricks | No Comments »
Posted on December 5, 2005 by thekhuc
The Javascript location object has 3 important properties: href, host, and protocol and 2 methods: replace() and reload()
location.href - returns the current URL
location.host - returns the current Host
location.protocol - returns the protocol used
window.location.href = “http://www.newurl.com” - sends user to “http://www.newurl.com”
window.location.replace(”http://www.newurl.com”) - sends user to “http://www.newurl.com”
setTimeout(”location.reload()”,100000) - refreshes the current page every 100 seconds
Filed under: Javascript, Tutorials and Tricks | No Comments »