Tuesday, July 01, 2008

Dojo auto popup dailog box on page load - part 2

Problem: On page load you want to pop up an existing dojo dialog
Solution: Use window.location.hash to get the id of the dialog which is being looked up. Unlike the previous post which talks about server side scripting, this would work with pure javascript and should work perfectly for Dojo tabs as well
Eg:
In head declare following javascript

<head>
<script>
function autoPopupDailog (dailogId) {
winHashName = window.location.hash.substr(1,window.location.hash.length);
if (winHashName == dailogId) {
if (dijit.byId(dailogId)) {dijit.byId(dailogId).show()};
}
}
dojo.addOnLoad(function () {autoPopupDailog('dailog1');});
</script>
</head>

Assuming that on the page there is some dialog existing with id 'dailog1, for auto popping up the url would become something like chandankumar.com/test.html#dailog1

0 comments:

Post a Comment