Monday, September 29, 2014

Use window.location to route to other pages within a web clip and NOT href attributes in anchor tags.

Having a "link" like so within a web clip...

<li onclick="goElsewhere('http://example.com/foo.html')">Go</li>

 
 

...which utilizes some JavaScript like this...

function goElsewhere(whereToGo) {
   window.location = whereToGo;
};

 
 

...is going to be superior to a traditional link like this...

<li><a href="http://example.com/foo.html"></a>Go</li>

 
 

...because the href links open their targets in new browser windows (outside of the web clip) and they do so even if you decorate the anchor tags with a target attribute of _top or _self unfortunately.

No comments:

Post a Comment