swn78
ToddOs wrote: |
- [...]
- Time to brush up on DHTML and Javascript, especially event handling. What it sounds like you want to do is attach an "onclick" handler for the links and then load/show/hide some data. A good place to start would be the gadget SDK. A word of advice -- if you're going to handle "onclick" for an anchor element (<a />), make sure you return false or the page will navigate to whatever href you've set (typically that will be "#" if you don't want the link to actually go somewhere). There's sample code out there, and you could look at the code behind any gadget up on Gallery if you know how to find it (it's not too difficult to find). As for being "easy to comprehend", that really depends on your familiarity and comfort level working with DHTML, Javascript, and CSS.
|
|
Thanks for the reply, Todd.
My problem being in this perticular case is that a Gadget page does not work the same way as a normal DHTML page would. As you said, I did use Javascripts event handling to launch an event when the link was clicked. I've confirmed that the event is really triggered by launching an alert message. This works, but how do I reload the conent which the gadget is displaying
The method I've tried is to set a variable with the html content, this content gets a new value when the link is clicked after which I call window.location.reload... that didnt work.
Ive looked at the code for the Quote of the Day gadget (I think this is one of the standard gadgets )..
The relevant part in this code:
spn.attachEvent(
"onclick",o);
/.../
function
o(p){
q(p.srcElement);
}
/.../
function
q(r,s){
if(!r||!r.feedUrl||!r.feedName||!r.channelId)
return;
if(r==m_activeTab)
return;
if(m_activeTab)
m_activeTab.className="Tab Channel"+m_activeTab.feedName;
m_activeTab=r;
m_activeTab.className="Tab_Current Channel"+m_activeTab.feedName;
if(!s)
B();
Start.RssManager.fetchFeed(m_baseFeedUrl+m_activeTab.feedUrl,Start.RssManager.MAX_ITEMS,t);
}
And my code:
function
onclick()
{
alert("Change content");
}
/.../
function
getLink(src, txt, page)
{
var newlink = document.createElement("a");
newlink.innerText = txt;
newlink.href = src;
newlink.attachEvent("onclick",onclick);
}
The above code generates a link which does launch an event, but I cant figure out how to reload/change content on the gadget page itself. On a normal web page I could just redirect the user to another page, but what am I supposed to do in this case Any suggestions appreciated.