InnerChild
asked on
JavaScript "Set Homepage" cookie
So really what I am looking for is a script that will ask the person to set the page they are at as their homepage. If they say yes it will remember them and never ask again. If no it will allow them to go about their business but the next time they come back it will ask again.
I think this is easy for most....just not me.
Thanks
IC
I think this is easy for most....just not me.
Thanks
IC
ASKER
It didn;t work the way I need it to but it is close. I need it to set it as the homepage as well.
Step by step
Person goes to homepage and is asked if they want to set that page as their homepage
if yes
then homepage is set to current homepage
if no
person can continue to browse website and if they come back they are asked again to set the page as their homepage.
Right now the window asks to remember but the homepage doesn't change.
Thanks
IC
Step by step
Person goes to homepage and is asked if they want to set that page as their homepage
if yes
then homepage is set to current homepage
if no
person can continue to browse website and if they come back they are asked again to set the page as their homepage.
Right now the window asks to remember but the homepage doesn't change.
Thanks
IC
<HTML>
<body onLoad="checkCookie()">
<script>
function setCookie() {
now=new Date()
now.setTime( now.getTime() + 1000 * 60 * 60 * 24 * 365)
document.cookie="visited=t rue; expires=" + now.toGMTString()
}
function checkCookie() {
if (!document.cookie)
if (confirm("Don't forgot me. OK?")) {
document.body.style.behavi or='url(#d efault#hom epage)';
document.body.setHomePage( location.h ref);
event.returnValue = false;
setCookie();
}
}
</script>
</body>
</html>
<body onLoad="checkCookie()">
<script>
function setCookie() {
now=new Date()
now.setTime( now.getTime() + 1000 * 60 * 60 * 24 * 365)
document.cookie="visited=t
}
function checkCookie() {
if (!document.cookie)
if (confirm("Don't forgot me. OK?")) {
document.body.style.behavi
document.body.setHomePage(
event.returnValue = false;
setCookie();
}
}
</script>
</body>
</html>
ASKER
Still not working I am getting a permissions error. I was doing some reading and I know you can't force the change and thet the user will need to accept it. Can the javascript just get that box to open asking the person if they want the homepage changed? As well as remember them?
Thanks
IC
Thanks
IC
<HTML XMLNS:IE>
<HEAD>
<STYLE>
@media all {
IE\:homePage {behavior:url(#default#hom epage)}
}
</STYLE>
<SCRIPT>
function fnSet(){
oHomePage.setHomePage(loca tion.href) ;
event.returnValue = false;
}
function setCookie() {
now=new Date()
now.setTime( now.getTime() + 1000 * 60 * 60 * 24 * 365)
document.cookie="visited=t rue; expires=" + now.toGMTString()
}
function checkCookie() {
if (!document.cookie) {
fnSet();
sQueryHome = oHomePage.isHomePage(locat ion.href);
if (sQueryHome) setCookie();
event.returnValue = false;
}
}
</SCRIPT>
</HEAD>
<BODY onLoad="checkCookie()">
<IE:homePage ID="oHomePage" />
</BODY>
</HTML>
<HEAD>
<STYLE>
@media all {
IE\:homePage {behavior:url(#default#hom
}
</STYLE>
<SCRIPT>
function fnSet(){
oHomePage.setHomePage(loca
event.returnValue = false;
}
function setCookie() {
now=new Date()
now.setTime( now.getTime() + 1000 * 60 * 60 * 24 * 365)
document.cookie="visited=t
}
function checkCookie() {
if (!document.cookie) {
fnSet();
sQueryHome = oHomePage.isHomePage(locat
if (sQueryHome) setCookie();
event.returnValue = false;
}
}
</SCRIPT>
</HEAD>
<BODY onLoad="checkCookie()">
<IE:homePage ID="oHomePage" />
</BODY>
</HTML>
ASKER
Still getting a error at line 11
oHomePage.setHomePage(loca tion.href) ;
permission denied
Thanks
IC
oHomePage.setHomePage(loca
permission denied
Thanks
IC
Is Frameset ? Are you try to run the above code individual ?
ASKER
Not in a frame just a static page.
Thanks
IC
Thanks
IC
IE Only.
I test above is work for me.
The setHomePage method I refer to MSDN.
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/reference/methods/sethomepage.asp
I test above is work for me.
The setHomePage method I refer to MSDN.
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/behaviors/reference/methods/sethomepage.asp
If still can't, could you post your run HTML source.
ASKER
All I did was a cut and paste from what you had.
<HTML XMLNS:IE>
<HEAD>
<STYLE>
@media all {
IE\:homePage {behavior:url(#default#hom epage)}
}
</STYLE>
<SCRIPT>
function fnSet(){
oHomePage.setHomePage(loca tion.href) ;
event.returnValue = false;
}
function setCookie() {
now=new Date()
now.setTime( now.getTime() + 1000 * 60 * 60 * 24 * 365)
document.cookie="visited=t rue; expires=" + now.toGMTString()
}
function checkCookie() {
if (!document.cookie) {
fnSet();
sQueryHome = oHomePage.isHomePage(locat ion.href);
if (sQueryHome) setCookie();
event.returnValue = false;
}
}
</SCRIPT>
</HEAD>
<BODY onLoad="checkCookie()">
<IE:homePage ID="oHomePage" />
</BODY>
</HTML>
Still getting a permissions error on 3 different machines.
Thanks
IC
<HTML XMLNS:IE>
<HEAD>
<STYLE>
@media all {
IE\:homePage {behavior:url(#default#hom
}
</STYLE>
<SCRIPT>
function fnSet(){
oHomePage.setHomePage(loca
event.returnValue = false;
}
function setCookie() {
now=new Date()
now.setTime( now.getTime() + 1000 * 60 * 60 * 24 * 365)
document.cookie="visited=t
}
function checkCookie() {
if (!document.cookie) {
fnSet();
sQueryHome = oHomePage.isHomePage(locat
if (sQueryHome) setCookie();
event.returnValue = false;
}
}
</SCRIPT>
</HEAD>
<BODY onLoad="checkCookie()">
<IE:homePage ID="oHomePage" />
</BODY>
</HTML>
Still getting a permissions error on 3 different machines.
Thanks
IC
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Just when you thought I was gone. The script works great in a static stie but I tried to use it in a ASP application where a header file has the <head> and <body> tags but nothing happens, not even a error. If you have any thoughts I would appricicate them.
Thanks
IC
Thanks
IC
don't miss the HTML declare
<HTML XMLNS:IE>
<HTML XMLNS:IE>
ASKER
It already has a wierd declare in the head tag '<head xmlns:eba>'
I think the way you did it was slick but I would rather have simple and working in the application, so do you have a simple popup version where when they get to the page the get a popup and when they click the link they are asked to bookmark the website and if they do then it never pops open again but if they don't then it will popup everytime they go there. If you can get this done I'll find a way of getting you more points.
Thanks
IC
I think the way you did it was slick but I would rather have simple and working in the application, so do you have a simple popup version where when they get to the page the get a popup and when they click the link they are asked to bookmark the website and if they do then it never pops open again but if they don't then it will popup everytime they go there. If you can get this done I'll find a way of getting you more points.
Thanks
IC
ASKER
nm
<body onLoad="checkCookie()">
<script>
function setCookie() {
now=new Date()
now.setTime( now.getTime() + 1000 * 60 * 60 * 24 * 365)
document.cookie="visited=t
}
function checkCookie() {
if (!document.cookie)
if (confirm("Remember you. OK?"))
setCookie();
}
</script>
</body>
</html>