It seems you jquery selector is not correct. It should be
$("#loadmenu").attr("src",SRConfig.WESHost + "/webapp/" + SRConfig.WESApp+ "/servlet/WPSNav?mod=iwswps&idkey=displayhome");
It seems you jquery selector is not correct. It should be
$("#loadmenu").attr("src",SRConfig.WESHost + "/webapp/" + SRConfig.WESApp+ "/servlet/WPSNav?mod=iwswps&idkey=displayhome");
Insert script tag instead:
$(document).ready(function(){
var scriptTag = $("<script/>");
scriptTag.attr("src",SRConfig.WESHost + "/webapp/" + SRConfig.WESApp+ "/servlet/WPSNav?mod=iwswps&idkey=displayhome");
$("head").append(scriptTag);
});
or use a similar code of facebook.
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "Your URL";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'loadmenu'));
Take a look at Detect if page has finished loading if it helps you.
Basically you can use .load function with window to see if it's fully loaded and trigger your script after that.
Documentation:
Is there a reason you are modifying the src
attribute in javascript ?
If the script path to load is determined by the hosted web application, I'm guessing you could simply do something like:
<script id="loadmenu" src="${SRConfig.WESHost}/webapp/${SRConfig.WESApp}/servlet/WPSNav?mod=iwswps&idkey=displayhome"></script>
The ${}
being replaced in your html template by your server side app.
I'm not familiar with the technology behind theses SRConfig.*
so I could be totally wrong.