Using Dynamic HTML with Active ChannelsUsing Dynamic HTML with Active Channels*
*



Contents  *



Index  *Topic Contents

*Previous Topic: Guidelines for Active Channel Logo Images
*Next Topic: Netcaster CDF Compatibility Notes

Using Dynamic HTML with Active Channels

A variety of Dynamic HTML features can be used to modify the appearance of a Web page, including changing the text or images that are displayed. As an example, the following steps show how a publisher might use the window.external.isSubscribed method to hide an Add Active Channel logo button if its associated channel is already subscribed.

Assuming the Add Active Channel button was placed on a Web page as previously described, the page would include the following Add Active Channel button:

<a name="channelA"
href="http://www.microsoft.com/ie/ie40/download/?/ie/ie40/download/redirect.htm">
<img src="IEAddChannel.gif" border=0 width=136 height=20></a>
<script language="JavaScript"> 
    if ( isMsie4orGreater()) { channelA.href ="urlToCDF"; }
</script> 

Step 1. Add the ID attribute to the anchor element. The value must be unique.

<a name="channelA" id="idA"
href="http://www.microsoft.com/ie/ie40/download/?/ie/ie40/download/redirect.htm">
<img src="IEAddChannel.gif" border=0 width=136 height=20></a>
<script language="JavaScript"> 
    if ( isMsie4orGreater()) { channelA.href ="urlToCDF"; }
</script>

Step 2. Include the following script between the page's <HEAD> and </HEAD> tags. Note that the isMsie4orGreater function should already exist in the HEAD section of this page.

<SCRIPT LANGUAGE="JavaScript">
function HideIfSubscribed(elementID, urlToCDF){
if (window.external.isSubscribed(urlToCDF)) {ss.addRule("#"+ elementID,"visibility: hidden");}}

var ss = null;
ss = document.createStyleSheet()
if(isMsie4orGreater()){ //Test if the browser is IE
// For each element you want to conditionally hide, include the following line
// (uniqueID is the unique value for the ID attribute of the element and
// urlToCDF is the URL to the channel's CDF).
HideIfSubscribed("uniqueID","urlToCDF");
}
</SCRIPT>

When using these scripts, remember that the URLs of the channels must include the same protocol and secondary domain name as the page that contains the scripts. Also, any element in Dynamic HTML that has the visibility property can be hidden using the same code.

The following HTML page shows a full example of the scripting shown above.

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
    function isMsie4orGreater() { 
        var ua = window.navigator.userAgent;   var msie = ua.indexOf ( "MSIE " );
        if  (msie > 0)
            {return (parseInt ( ua.substring ( msie+5, ua.indexOf ( ".", msie ) ) ) >=4)
			&& (ua.indexOf("MSIE 4.0b") <0) ;}
        else    {return false;}}

    function HideIfSubscribed(elementID, urlToCDF){
        if (window.external.isSubscribed(urlToCDF))
		{ss.addRule("#"+ elementID,"visibility: hidden");}}

    var ss = null;
    if(isMsie4orGreater()){ //Test if the browser is IE
        ss = document.createStyleSheet()
        HideIfSubscribed("idA","http://www.mycorp.com/channelA.cdf");
    }
</SCRIPT>
</HEAD>

<BODY>
<a name="channelA" id="idA"
href="http://www.microsoft.com/ie/ie40/download/?/ie/ie40/download/redirect.htm">
<img src="IEAddChannel.gif" border=0 width=136 height=20></a>
<script language="JavaScript"> 
    if ( isMsie4orGreater()) { channelA.href ="urlToCDF"; }
</script>

</BODY>
</HTML>

If the Web page contains more than one Add Active Channel or Add to Active Desktop logo button, the name and ID attributes must be unique.


Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.