Tuesday 15 May 2012

Javascript: Show content according to URL -



Javascript: Show content according to URL -

my code supposed display text based on url, logic simple:

if page ht-tp://sitedotcom/thefirstpage (sef), displays text, else, if page ht-tp://sitedotcom/thesecondpage text hidden. set work specifying absolute url including file extension, ht-tp://sitedotcom/thefirstpage.html, need work sef url.

here code:

<script>// <![cdata[ var pages = window.location.href; if( pages.indexof( 'http://akecheta.com/free-blogger-templates/' ) > -1 ) { document.write('<b>hello world</b>'); } else { document.write(''); } // ]]></script>

replace url after indexof url on page you're testing. remember not supposed tested file extensions.

the solution how can insert html text in javascript right way?

as understand trying perform based on url , guess doing right way i.e. check url , perform.

other way can suggest utilize query string, based on query string can perform actions. hope helps.

javascript show

No comments:

Post a Comment