Page 2 of 2 FirstFirst 12
Results 11 to 19 of 19

Thread: Google Set Homepage Script

  1. #11
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Since I posted I tried this out, this is all you need, goes in the body:

    Code:
    <span id=hp style="behavior:url(#default#homepage)"></span>
    <script type="text/javascript">
    //<!--
    if (!hp.isHomePage('http://www.google.com/')) {document.write("<p><a href=\"#\" onclick=\"style.behavior='url(#default#homepage)';setHomePage('http://www.google.com/');window.location.href=window.loction.href;return false;\">Make Google Your Homepage!</a>");}
    //-->
    </script>
    However, both instances of:

    http://www.google.com/

    must be changed to your domain or page and be identical to each other as well as to the domain root or (if doing a page) to the address that shows in the address bar. It must be live on the page. If you are doing a domain, it must be live in the root of the domain. As mentioned before, it is IE only. Of course, you should also change:

    Make Google Your Homepage!

    To text appropriate to your page or domain.

    You can also do the root of a subdirectory, following all the same rules as though it were a domain. That last part I only tested on a domain name server so, it may not work if you have a directory on say freewebs or something like that.
    Last edited by jscheuer1; 05-31-2006 at 07:31 AM. Reason: spelling
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  2. #12
    Join Date
    May 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I did the same thing! If you go back to the first post of this thread, you see i have the same piece of code. However, it doesn't disappear after you click on the link. And I did change the google.com part to my own domain name.

    Does your link disappear after you set the page to be your homepage?

  3. #13
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yes it disappears. Post a link to your page.

    And look again, the code is not identical.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #14
    Join Date
    May 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by jscheuer1
    Yes it disappears. Post a link to your page.

    And look again, the code is not identical.
    I was gonna say John you the man!
    Then,
    Dunno if I did something wrong(I copied and pasted the code into the body of my code), but it doesn't work. The botton of the screen also says "error". You think it's possible to show us your page/link?

  5. #15
    Join Date
    May 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    When I say disappear I meant,
    if the homepage is google.com already, then the page will still show, but just the link itself disappear, any kind of redirect of pages doesn't count. Just wanna clarify.

  6. #16
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I made a typo in the second 'location', leaving out the 'a'. This is what caused the error which then cascades into other problems. Here is a working version of my code, the address used is the live page, the link appears in the upper left corner of the page on a dark background, so is hard to see but, it is there:

    Code:
    <span id=hp style="behavior:url(#default#homepage)"></span>
    <script type="text/javascript">
    //<!--
    if (!hp.isHomePage('http://www.statestreetblues.com/2006/index2.html')) {document.write("<p><a href=\"#\" onclick=\"style.behavior='url(#default#homepage)';setHomePage('http://www.statestreetblues.com/2006/index2.html');window.location.href=window.location.href;return false;\">Make The Blues Stroll Homepage!</a>");}
    //-->
    </script>
    Once you get the code corrected on your page, make sure to clear your cache, reload, and make sure there is no hash (#) in the address bar.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  7. #17
    Join Date
    May 2006
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    John you the Man!
    I tried it and it worked perfectly. I'm sure this piece of code will benefit a lot of people who come here.

  8. #18
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Thanks. I was playing around with this just a bit more and discovered there were errors in FF and Opera. Nothing that would 'stop the show' but annoying to any purist. Plus, this code would make any page not validate. If you put IE conditional comments around it, all that goes away and it still works fine in IE, I also added variables that allow you to configure the page or domain and text shown in just one spot (highlighted red):

    Code:
    <!--[if gte IE 5.5]>
    <span id=hp style="behavior:url(#default#homepage)"></span>
    <script type="text/javascript">
    var thePage='http://www.statestreetblues.com/2006/index2.html'
    var theText='Make The Blues Stroll Your Homepage!'
    if (!hp.isHomePage(thePage)) {document.write("<p><a href=\"#\" onclick=\"style.behavior='url(#default#homepage)';setHomePage(thePage);window.location.href=window.location.href;return false;\">"+theText+"</a>");}
    
    </script>
    <![endif]-->
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  9. #19
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Nice
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •