Baumeister Mediasoft Engineering BME - Baumeister Mediasoft Engineering  JavaScript Methods - English Version JavaScript-Methoden - Deutsche Version
Baumeister Mediasoft Engineering
Bartels AutoEngineerCarLogServicesResourcesCompany ProfileContact Us
Baumeister Mediasoft Engineering » Resources » Web Development » JavaScript » Methods
JavaScript (ECMAScript)

JavaScript Methods

Baumeister Mediasoft Engineering

Sitemap

Last Change

JavaScript Methods 
JavaScript Method AddFavorite (IE4) 29/10/2008
JavaScript Method print 29/10/2008
JavaScript Method setHomePage (IE5) 29/10/2008
 

JavaScript Method AddFavorite (IE4)

The AddFavorite() JavaScript function can be used in Internet Explorer (version 4 or higher) to add a web address (with a title) to the Internet Explorer favorites. AddFavorite() activates the Add to Favorites... function from the Internet Explorer Favorites menu with the given parameters.

The following AddFavorite() call can be used to add the BME website address with its title to the Internet Explorer favorites:

window.external.AddFavorite(
    
'http://www.bme.ie',
    
'BME - Baumeister Mediasoft Engineering'
    
);

The following AddFavorite() call can be used to add the currently loaded page to the Internet Explorer favorites:

window.external.AddFavorite(location.hrefdocument.title);

A web browser compatibility check such as

if (window.external)
{
   
window.external.AddFavorite(location.hrefdocument.title);
}

is recommended since AddFavorite() is only available in Internet Explorer (version 4 or higher).

onclick() can be used to provide a clickable link to the AddFavorite() function call. The following JavaScript code displays a link for adding the currently loaded page to the Internet Explorer favorites:

<script type="text/javascript">
<!--
//--><![CDATA[//><!--
if (window.external)
{
    
document.write(
        
'<a href="#"'
        
' onclick="window.external.AddFavorite(location.href,document.title);">'
        
'Add this Page to your Favorites...</a>'
        
);
}
//--><!]]>
</script>

JavaScript Method print

The JavaScript print() function can be used to print the currently loaded web document, exactly as if the user had activated the browser's Print function:

print();

The print() function can be used to provide a link:

<a href="javascript:print();">Print this Page</a>

Working example:

Print this Page

JavaScript Method setHomePage (IE5)

The setHomePage() JavaScript function uses a DHTML behavior in Internet Explorer (version 5 or higher) to set the user's Homepage. setHomePage() can be applied to objects with the following style attribute:

behavior:url(#default#homepage)

setHomePage() expects a web address as argument. The following setHomePage() call uses the BME website address:

this.setHomePage('http://www.bme.ie')

The following JavaScript statements can be used to set the Homepage address to the URL of the currently loaded web page:

this.style.behavior='url(#default#homepage)';
this.setHomePage(location.href);

A web browser compatibility check such as

if (window.external)
{
    
this.style.behavior='url(#default#homepage)';
    
this.setHomePage(location.href);
}

is recommended since setHomePage() is only available in Internet Explorer (version 5 or higher).

onclick() can be used to provide a clickable link to the setHomePage() function call. The following JavaScript code displays a link for setting the Homepage address to the URL of the currently loaded web page. The required behaviour attribute is assigned through a style attribute within the span tag:

<script type="text/javascript">
<!--
//--><![CDATA[//><!--
if (window.external)
{
    
document.write(
       
'<span style="color:blue;cursor:hand;behavior:url(#default#homepage);"'
       
' onclick="this.setHomePage(location.href);">'
       
'Make this Page your Homepage...'
       
'</span>'
       
);
}
//--><!]]>
</script>

For security reasons, setHomePage() causes Internet Explorer to activate a confirmation dialog for changing the Homepage setting.

Baumeister Mediasoft Engineering » Resources » Web Development » JavaScript » Methods

JavaScript Methods • © 2017 Manfred Baumeister

Baumeister Mediasoft Engineering, Clontarf, Dublin 3, Ireland
© 2017 Manfred Baumeister

JavaScript Methods - English Version JavaScript-Methoden - Deutsche Version