开发者

Run JS function on page load if condition

I have the following link which opens a dom window...

<a href='#inlineContent' clas开发者_如何转开发s='defaultDOMWindow'>(edit interests)</a><br /><br />";?>

    <script type='text/javascript'> 
    $('.defaultDOMWindow').openDOMWindow({ 
    eventType:'click', 
    loader:1, 
    loaderImagePath:'animationProcessing.gif', 
    loaderHeight:16, 
    loaderWidth:17 
    }); 
    </script> 
    <div id='inlineContent' style='display: none;'> 
    <h1 class='login-hdr'>Your Interests!</h1>

What I need to do is if a user visits a certain url eg, www.mysite.com#DOMwindow the DOM window would then load without the user having to click the link, but if he visits the url normally with www.mysite.com the window would not load, im not sure if this is possible but thought id ask...


I don't know what openDOMWindow() does, but I suspect/guess it is attaching a click event to .defaultDOMWindow. If so, try the following:

$(document).ready(function(){
    $('.defaultDOMWindow').openDOMWindow({ 
        eventType:'click', 
        loader:1, 
        loaderImagePath:'animationProcessing.gif', 
        loaderHeight:16, 
        loaderWidth:17 
    });
    // if the visitor requests www.mysite.com#DOMwindow
    // trigger a click event on the .defaultDOMWindow
    // thus the window will be opened automatically on load time
    if(window.location.hash == '#DOMwindow'){
        $('.defaultDOMWindow').trigger('click');
    }
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜