Month: January 2010

H

How to determine whether Javascript is enabled?

There are a lot of approaches to this. Lets take them one at a time: Using NOSCRIPT tag: You can write a noscript tag just before your script tag to display the user a warning message. Check the code below, wherein the user will be redirected to another page if javascript is disabled: <html> <head> ...

J

Javascript to check any redirection to another page

When the user had made some changes in the page and accidentally clicks some links on the page, you might want to warn the user about the redirection and ask his permission for the operation. Javascript makes it quite simple to do this operation, with the help of window.onbeforeunload(): window.onbeforeunload = checkRedirection; function checkRedirection (evt) ...

J

Javascript to maximise window on load

Well this is simple script to get your browser maximised onload: <html> <head> <script language="JavaScript"> window.onload = maxWindow; function maxWindow() { window.moveTo(0,0); if (document.all) { top.window.resizeTo(screen.availWidth,screen.availHeight); } else if (document.layers||document.getElementById) { if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth) { top.window.outerHeight = screen.availHeight; top.window.outerWidth = screen.availWidth; } } } </script> </head> <body>Testing</body> </html> I just tested it it IE. Hope this ...

H

How to suppress nagging javascript errors?

To suppress javascript error popups and warnings in your browser, just use the code snippet below: <SCRIPT language="JavaScript"> <!-- function silentErrorHandler() {return true;} window.onerror=silentErrorHandler; //--> </SCRIPT> This however has some limitation, from what i had experienced. It works well in IE, to a major extend in Firefox, but not much in Opera and Safari. Hence ...

D

Difference between Convert.ToString() and .ToString()

The main difference between these both are the fact that Convert.ToString() can handle NULL and avoid ObjectReferenceNullException, while .ToString() would break in such case. It is always good to use the Convert object than the ToString() Let's have a look into the Convert.ToString() method. Using a reflector, i got hold of the Convert object below: ...

I

Internet Explorer Bugs

Internet explorer is considered as the most widely used browser over the internet. However, this buddy comes up with some weird bugs in every version of it. I will be giving you a high level view of the bugs that IE has got. To get the indepth view of these bugs, i would recommend you ...

A

Avoid Outline for textboxes on focus in Safari

Safari has its own amazing styles with it. Most of them are pretty cool and makes the browser stand out. But some of them can affect the screen structure. One of them would be the blue outline that textboxes have on focus. The solution to this is a simple css fix. input:focus{ outline : none ...

A

Avoid Resizing of textarea in Safari

Safari has its own amazing styles with it. Most of them are pretty cool and makes the browser stand out. But some of them can affect the screen structure. One of them would be the resizing of the multiline textboxes or textarea in Safari. But the solution is quite simple css fix. In the css ...

C

CSS fixes based on Browser versions

IE Specific CSS loading: There can be scenarios wherein you might want to load IE version specific CSS. Say an IE6.css file for IE 6 and below, IE7.css for IE 7 alone. In these scenarios, it is good to exploit the conditional comments that IE layout engine Trident look upon. Check the code below to ...

j

jQuery not working from external js file?

I had faced this issue in one of my development projects. I used jquery lavishly in every bit of my javascript code. Since during development, i used to write the scripts in the page itself, i didn't have to bother much. But later when i decided to move the scripts to another external ".js" file, ...