Showing posts with label JavaScript. Show all posts
Showing posts with label JavaScript. Show all posts

Thursday, April 9, 2009

Bookmark in Firefox and Internet Explorer

Add this function into your head tag and call it. This works for both Firefox and Internet Explorer.

function add_to_fav(title, url){
if(document.all)
{
window.external.AddFavorite(url, title);
}
else if(window.sidebar)
{
window.sidebar.addPanel(title, url, "")
}
}

and call like this; add_to_fav('My blog', 'http://raza-ali.blogspot.com/')

Duplicate content of Ajax call using facebox with jQuery in Internet Explorer

Problem: In Internet Explorer 7, populating once facebox lightbox using Ajax call works fine but if I repeat that calls it starts duplicating the content of the lightbox, gave impression that it appends new call at the end of already populated content and only doing hide and show of the lightbox content.

Solution: After debugging I noticed that in my Ajax call I am calling a whole web-page including HTML and BODY pair tags. So removing HTML tags and only fetching relevant DIV content solved my problem :)

Sunday, November 16, 2008

Get selected value using JavaScript from select Tag

Getting selected value from drop-down interface or select HTML Tag using JavaScript.

use this code:

document.getElementById('book')
.options[document.getElementById('book').selectedIndex].innerHTML;


details,
document.getElementById('book').selectedIndex, this will give you selected option index

then using that index we can get selected optoin HTML object such as, document.getElementById('book').options[index]

and finally getting its value just use innerHTML property, in my case selected book name.