Zvona
12-27-2005, 10:24 AM
I found following code for IE & FF:
<script type="text/javascript">
function setHomepage()
{
if (document.all)
{
this.style.behavior = 'url(#default#homepage)';
this.setHomePage(location.href);
}
else
{
var ea = document.createEvent("MouseEvents");
ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);
var eb = document.getElementsByTagName("head")[0];
eb.ownerDocument getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
eb.dispatchEvent(ea);
}
}
</script>
However the code isn't working. FF simply does nothing and IE announces and error. If I remove line:
eb.ownerDocument getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
IE starts working properly.
Could there be some kind of (security) restrictions concerning the line above, because the code itself seems to be correct?
<script type="text/javascript">
function setHomepage()
{
if (document.all)
{
this.style.behavior = 'url(#default#homepage)';
this.setHomePage(location.href);
}
else
{
var ea = document.createEvent("MouseEvents");
ea.initMouseEvent("mousedown",1,1,window,1,1,1,1,1,0,0,0,0,1,null);
var eb = document.getElementsByTagName("head")[0];
eb.ownerDocument getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
eb.dispatchEvent(ea);
}
}
</script>
However the code isn't working. FF simply does nothing and IE announces and error. If I remove line:
eb.ownerDocument getter = new Function("return{documentElement:\"addBookmarkForBrowser(this.docShell);\",getBoxObjectFor:eval}");
IE starts working properly.
Could there be some kind of (security) restrictions concerning the line above, because the code itself seems to be correct?