Submit Your Article Forum Rules

Results 1 to 10 of 10

Thread: Conditional Redirect with Javascript..

  1. #1
    Senior Member
    Join Date
    May 2004
    Posts
    199

    Conditional Redirect with Javascript..

    I found another web site has copied one of my websites.. designs, navigation, etc..

    They are even linking to a javascript on my server..

    What I wondering if it is possible to initiate a redirect whenever someone views
    the copied site, and invokes the javascript from my server..

    i.e. visitor is viewing www.badsite.com
    When the javascript on my site is called..

    if hostsite=badsite{
    window.location="http://www.mydomain.com/
    }else{
    normal script functions
    }


    To bring them over to my site..

    Make sense?

    Thanks!

  2. #2
    Senior Member weslinda's Avatar
    Join Date
    Mar 2006
    Posts
    975

    You could do that...or?

    You could do that, or you could simply change the name of the script, and that will cause a bit of havic with their sites, as long as the script is very important.

    You can also close off access to the source of your pages with a script that would stop them from being able to copy your design as easily.
    We offer a total eCommerce solution with eCommerce Web Design using Pinnacle Cart

  3. #3
    Senior Member stymiee's Avatar
    Join Date
    May 2006
    Posts
    427
    You should consider using .htaccess' hotlink protection. That way you can block them completely and even create havoc on their website.

  4. #4
    Senior Member weslinda's Avatar
    Join Date
    Mar 2006
    Posts
    975

    Not familiar with this...

    Hey Stymiee, can you send a link or something with more information on this? This is a feature set I am not familiar with.
    We offer a total eCommerce solution with eCommerce Web Design using Pinnacle Cart

  5. #5
    Senior Member stymiee's Avatar
    Join Date
    May 2006
    Posts
    427
    Preventing Hotlinking with Apache mod_rewrite

    Not only can you block them completely, but you can even send them bogus files. If someone is hotlinking to an image file you can send another file in its place that says they are stealing from you or worse. ;)

  6. #6
    Senior Member weslinda's Avatar
    Join Date
    Mar 2006
    Posts
    975

    Thanks...

    Nice, learn something new every day. Now I can head off to bed.
    We offer a total eCommerce solution with eCommerce Web Design using Pinnacle Cart

  7. #7
    Senior Member
    Join Date
    May 2004
    Posts
    199
    The .htaccess is do-able.. and I can substitute a different javascript..but,

    I was hoping to use the redirect in the existing file to get the visitors to my site..
    since the offender is in the same market as our site.

    So can anyone provide a javascript solution?

  8. #8
    Senior Member sands's Avatar
    Join Date
    Sep 2005
    Posts
    392

    Re: Conditional Redirect with Javascript..

    Quote Originally Posted by steve0
    i.e. visitor is viewing www.badsite.com
    When the javascript on my site is called..

    if hostsite=badsite{
    window.location="http://www.mydomain.com/
    }else{
    normal script functions
    }

    To bring them over to my site..
    Sorry for the belated reply to this post. Somehow I missed it. Anyway if still interested try this code:
    Code:
    if (document.title=="The Bad Site's Title") { location.href="http://www.mydomain.com/"; }
    Add it to the top of your .js file they are linking to. i.e. find out the Bad Site document title and paste it in the code above. This will redirect the visitors to Bad Site to your site if the title matches.

  9. #9
    Member
    Join Date
    Jul 2006
    Posts
    30
    If you put this in the top of the JS pf it's not your sites url it will redirect to your url

    Code:
    if(document.domain.toLowerCase() !='www.yoururl.com') {window.location='http://www.yoururl.com'}
    Martyn
    Martyn-it

  10. #10
    Senior Member sands's Avatar
    Join Date
    Sep 2005
    Posts
    392
    Quote Originally Posted by martyn-it
    Code:
    if(document.domain.toLowerCase() !='www.yoururl.com') {window.location='http://www.yoururl.com'}
    Yes, this is one more option. If you want you could also have an alert popup that gives notice of the fact that Bad Site is stealing content:
    Code:
    if (location.href=='http://www.badsite.com') { window.alert("Warning, BadSite.com is stealing content from MyDomain.com!\nYou shall now be redirected to MyDomain.com!"); location.href="http://www.mydomain.com"; }

Similar Threads

  1. Conditional Tag tip and help please?
    By inertia in forum WordPress Discussion Forum
    Replies: 2
    Last Post: 06-29-2009, 01:46 PM
  2. conditional ie - can't get it to work:(
    By ristenk1 in forum Graphics & Design Discussion Forum
    Replies: 15
    Last Post: 04-15-2009, 03:53 AM
  3. Can javascript redirect harm website
    By Ann in forum Search Engine Optimization Forum
    Replies: 28
    Last Post: 10-08-2007, 01:21 AM
  4. Best way to handle redirect if no javascript
    By sdadesky in forum Search Engine Optimization Forum
    Replies: 1
    Last Post: 11-06-2005, 11:53 AM
  5. Does Javascript redirect affect yahoo ranking?
    By reddy in forum Yahoo! Discussion Forum
    Replies: 1
    Last Post: 07-12-2004, 11:43 AM

Posting Permissions

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