Page 1 of 2 12 LastLast
Results 1 to 16 of 17

Thread: Frames & Javascript redirect

  1. #1
    chown -R me ./base BlackDwarf's Avatar
    Join Date
    Sep 2005
    Location
    On Teh Internets
    Posts
    1,431
    Thanks
    17
    Thanked
    33 times in 29 posts
    • BlackDwarf's system
      • Motherboard:
      • Gigabyte Z77-D3H
      • CPU:
      • Intel i5 3570k @ 4.5Ghz w/ Corsair H100i
      • Memory:
      • 16Gb Corsair Vengeance PC3-12800
      • Storage:
      • 120Gb Samsung 850 EVO, 60Gb Crucial M4 & 2TB Seagate
      • Graphics card(s):
      • EVGA 980 Ti Hybrid
      • PSU:
      • Coolermaster 550W Modular
      • Case:
      • Corsair 540 Air
      • Operating System:
      • Windows 10 x64
      • Monitor(s):
      • 2x 24" Dell U2314H
      • Internet:
      • Sky Fiber 80Mb/20Mb

    Unhappy Frames & Javascript redirect

    Hey all.

    I'm trying to get a particular issue sorted for my site.

    I've created it using frames, which, in hindsight, was a bad idea, but my overall lack of knowledge of how to do anything else prevailed.

    Anyway, the issue I have is that when Google comes around to crawling my site, it may bring up pages to customers who will load them out of the context of the frames. After some searching, i've got a script on my index.html, and on each page, that if the page is loaded outside of the frames, redirects to the index.html, which in turn brings up the page they were on in the main frame of the site.

    The problem I'm having, is that the script works for pages within the same directory as index.html, but refuses to work in subdirectories, where most of the pages are held. For example, /products/photography.html.

    The code I've got on the page is as follows:
    Code:
    <SCRIPT language="JavaScript">
    
    <!--
    function Framed()
    {
    if (!top.frames[1]) 
    	{
    	location.href = "index.html?page=products/photography.html"
    	}
    }
    // -->
    </SCRIPT>
    This doesn't seem to work, neither does adding a slash before the "products" folder.

    Am I doing something really stupid? The script itself does, as I've got another page working.

    Also, is this way of doing it likely to get my sites downgraded or removed from google, for what is essentially spoof redirection?

    Thanks
    Diablo (Main PC): Corsair Air 540; Gigabyte Z77-D3H; i5 3570k @ 4.4Ghz; 16Gb Corsair Vengeance PC3-12000; 120Gb Samsung 840 EVO; EVGA 980 Ti Hybrid; 2x Dell U2414H; Windows 10 x64.
    Imperius (VM Server): 2x Intel 5640, 64Gb RAM, 2x1Tb, 6x Intel NIC, VMware ESX 5.5
    Tyrael (File Server): Synology DS410 w/ 4x HD154UI; 2Gb RAM; DSM 5.2

  2. #2
    PHP Geek Flash477's Avatar
    Join Date
    Dec 2008
    Location
    Devon
    Posts
    822
    Thanks
    51
    Thanked
    72 times in 65 posts

    Re: Frames & Javascript redirect

    put a slash before index.html

  3. #3
    chown -R me ./base BlackDwarf's Avatar
    Join Date
    Sep 2005
    Location
    On Teh Internets
    Posts
    1,431
    Thanks
    17
    Thanked
    33 times in 29 posts
    • BlackDwarf's system
      • Motherboard:
      • Gigabyte Z77-D3H
      • CPU:
      • Intel i5 3570k @ 4.5Ghz w/ Corsair H100i
      • Memory:
      • 16Gb Corsair Vengeance PC3-12800
      • Storage:
      • 120Gb Samsung 850 EVO, 60Gb Crucial M4 & 2TB Seagate
      • Graphics card(s):
      • EVGA 980 Ti Hybrid
      • PSU:
      • Coolermaster 550W Modular
      • Case:
      • Corsair 540 Air
      • Operating System:
      • Windows 10 x64
      • Monitor(s):
      • 2x 24" Dell U2314H
      • Internet:
      • Sky Fiber 80Mb/20Mb

    Re: Frames & Javascript redirect

    Like this?
    Code:
    <SCRIPT language="JavaScript">
    
    <!--
    function Framed()
    {
    if (!top.frames[1]) 
    	{
    	location.href = "/index.html?page=products/photography.html"
    	}
    }
    // -->
    </SCRIPT>
    Didn't work.
    I've also tried variations of all of these placements:
    Code:
    <SCRIPT language="JavaScript">
    
    <!--
    function Framed()
    {
    if (!top.frames[1]) 
    	{
    	location.href = "/index.html/?page=/products/photography.html"
    	}
    }
    // -->
    </SCRIPT>
    Nothing seems to work right.
    Diablo (Main PC): Corsair Air 540; Gigabyte Z77-D3H; i5 3570k @ 4.4Ghz; 16Gb Corsair Vengeance PC3-12000; 120Gb Samsung 840 EVO; EVGA 980 Ti Hybrid; 2x Dell U2414H; Windows 10 x64.
    Imperius (VM Server): 2x Intel 5640, 64Gb RAM, 2x1Tb, 6x Intel NIC, VMware ESX 5.5
    Tyrael (File Server): Synology DS410 w/ 4x HD154UI; 2Gb RAM; DSM 5.2

  4. #4
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,230
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Frames & Javascript redirect

    I take it there's some code in index.html that uses the querystring variable to load the correct page? My guess is that the issue will be there - perhaps you could post up that code too?

  5. #5
    chown -R me ./base BlackDwarf's Avatar
    Join Date
    Sep 2005
    Location
    On Teh Internets
    Posts
    1,431
    Thanks
    17
    Thanked
    33 times in 29 posts
    • BlackDwarf's system
      • Motherboard:
      • Gigabyte Z77-D3H
      • CPU:
      • Intel i5 3570k @ 4.5Ghz w/ Corsair H100i
      • Memory:
      • 16Gb Corsair Vengeance PC3-12800
      • Storage:
      • 120Gb Samsung 850 EVO, 60Gb Crucial M4 & 2TB Seagate
      • Graphics card(s):
      • EVGA 980 Ti Hybrid
      • PSU:
      • Coolermaster 550W Modular
      • Case:
      • Corsair 540 Air
      • Operating System:
      • Windows 10 x64
      • Monitor(s):
      • 2x 24" Dell U2314H
      • Internet:
      • Sky Fiber 80Mb/20Mb

    Re: Frames & Javascript redirect

    Sure:

    Code:
    <script type="text/javascript">
    function querySt(k) {
      qs = window.location.search.substring(1);
      pairs = qs.split("&");
      for (i=0;i<pairs.length;i++) {
        kv = pairs[i].split("=");
        if (kv[0] == k) {
          return kv[1];
        }
      }
      return '';
    }
    
    window.onload = function()
    {
      var page = querySt('page');
      if (page != '')
      {
        document.getElementById('mainFrame').src = page;
      }
    }
    </script>
    Diablo (Main PC): Corsair Air 540; Gigabyte Z77-D3H; i5 3570k @ 4.4Ghz; 16Gb Corsair Vengeance PC3-12000; 120Gb Samsung 840 EVO; EVGA 980 Ti Hybrid; 2x Dell U2414H; Windows 10 x64.
    Imperius (VM Server): 2x Intel 5640, 64Gb RAM, 2x1Tb, 6x Intel NIC, VMware ESX 5.5
    Tyrael (File Server): Synology DS410 w/ 4x HD154UI; 2Gb RAM; DSM 5.2

  6. #6
    PHP Geek Flash477's Avatar
    Join Date
    Dec 2008
    Location
    Devon
    Posts
    822
    Thanks
    51
    Thanked
    72 times in 65 posts

    Re: Frames & Javascript redirect

    Is the site under a subdirectory?

    i.e. yourdomain.com/user/index.html

  7. #7
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS

    Re: Frames & Javascript redirect

    When you say "didn't work", you need to be more specific. What exact URL does it try to load, indicating a failure?

  8. #8
    chown -R me ./base BlackDwarf's Avatar
    Join Date
    Sep 2005
    Location
    On Teh Internets
    Posts
    1,431
    Thanks
    17
    Thanked
    33 times in 29 posts
    • BlackDwarf's system
      • Motherboard:
      • Gigabyte Z77-D3H
      • CPU:
      • Intel i5 3570k @ 4.5Ghz w/ Corsair H100i
      • Memory:
      • 16Gb Corsair Vengeance PC3-12800
      • Storage:
      • 120Gb Samsung 850 EVO, 60Gb Crucial M4 & 2TB Seagate
      • Graphics card(s):
      • EVGA 980 Ti Hybrid
      • PSU:
      • Coolermaster 550W Modular
      • Case:
      • Corsair 540 Air
      • Operating System:
      • Windows 10 x64
      • Monitor(s):
      • 2x 24" Dell U2314H
      • Internet:
      • Sky Fiber 80Mb/20Mb

    Re: Frames & Javascript redirect

    The site is www.mydomain.com. For examples sake. Pages with the above code in the site root work fine with the redirection. Pages deeper into the directory structure, for example www.mydomain.com/products/spamware.html, just load up the page as normal, in there non-frame context, and don't redirect like the pages in the site root.

    Does that make any sense?
    Diablo (Main PC): Corsair Air 540; Gigabyte Z77-D3H; i5 3570k @ 4.4Ghz; 16Gb Corsair Vengeance PC3-12000; 120Gb Samsung 840 EVO; EVGA 980 Ti Hybrid; 2x Dell U2414H; Windows 10 x64.
    Imperius (VM Server): 2x Intel 5640, 64Gb RAM, 2x1Tb, 6x Intel NIC, VMware ESX 5.5
    Tyrael (File Server): Synology DS410 w/ 4x HD154UI; 2Gb RAM; DSM 5.2

  9. #9
    PHP Geek Flash477's Avatar
    Join Date
    Dec 2008
    Location
    Devon
    Posts
    822
    Thanks
    51
    Thanked
    72 times in 65 posts

    Re: Frames & Javascript redirect

    Is it redirecting at all?

  10. #10
    Comfortably Numb directhex's Avatar
    Join Date
    Jul 2003
    Location
    /dev/urandom
    Posts
    17,074
    Thanks
    228
    Thanked
    1,027 times in 678 posts
    • directhex's system
      • Motherboard:
      • Asus ROG Strix B550-I Gaming
      • CPU:
      • Ryzen 5900x
      • Memory:
      • 64GB G.Skill Trident Z RGB
      • Storage:
      • 2TB Seagate Firecuda 520
      • Graphics card(s):
      • EVGA GeForce RTX 3080 XC3 Ultra
      • PSU:
      • EVGA SuperNOVA 850W G3
      • Case:
      • NZXT H210i
      • Operating System:
      • Ubuntu 20.04, Windows 10
      • Monitor(s):
      • LG 34GN850
      • Internet:
      • FIOS

    Re: Frames & Javascript redirect

    Shove an alert in the if, to see if it's being called or not. My guess is not.

    Try:

    Code:
    if (self.location==top.location) 
    	{
    	self.location = "/index.html?page=products/photography.html"
    	}

  11. #11
    chown -R me ./base BlackDwarf's Avatar
    Join Date
    Sep 2005
    Location
    On Teh Internets
    Posts
    1,431
    Thanks
    17
    Thanked
    33 times in 29 posts
    • BlackDwarf's system
      • Motherboard:
      • Gigabyte Z77-D3H
      • CPU:
      • Intel i5 3570k @ 4.5Ghz w/ Corsair H100i
      • Memory:
      • 16Gb Corsair Vengeance PC3-12800
      • Storage:
      • 120Gb Samsung 850 EVO, 60Gb Crucial M4 & 2TB Seagate
      • Graphics card(s):
      • EVGA 980 Ti Hybrid
      • PSU:
      • Coolermaster 550W Modular
      • Case:
      • Corsair 540 Air
      • Operating System:
      • Windows 10 x64
      • Monitor(s):
      • 2x 24" Dell U2314H
      • Internet:
      • Sky Fiber 80Mb/20Mb

    Re: Frames & Javascript redirect

    No, no redirection at all.
    And that code doesn't seem to make any different mate

    Starting to think I'll just have to stick a "Home" button at the bottom of each page. Would be a lot easier!
    Diablo (Main PC): Corsair Air 540; Gigabyte Z77-D3H; i5 3570k @ 4.4Ghz; 16Gb Corsair Vengeance PC3-12000; 120Gb Samsung 840 EVO; EVGA 980 Ti Hybrid; 2x Dell U2414H; Windows 10 x64.
    Imperius (VM Server): 2x Intel 5640, 64Gb RAM, 2x1Tb, 6x Intel NIC, VMware ESX 5.5
    Tyrael (File Server): Synology DS410 w/ 4x HD154UI; 2Gb RAM; DSM 5.2

  12. #12
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,230
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Frames & Javascript redirect

    Where do you call the Framed() function? As a function it won 't do anything until it's called, so make sure you're not missing a <body onload="Framed();"> call or some such.

    Also check the error console to see if there are any javascript errors being reported.

    And remember that javascript is case sensitive, so onload="framed()" is different to onload="Framed()"...

  13. Received thanks from:

    BlackDwarf (08-06-2010)

  14. #13
    chown -R me ./base BlackDwarf's Avatar
    Join Date
    Sep 2005
    Location
    On Teh Internets
    Posts
    1,431
    Thanks
    17
    Thanked
    33 times in 29 posts
    • BlackDwarf's system
      • Motherboard:
      • Gigabyte Z77-D3H
      • CPU:
      • Intel i5 3570k @ 4.5Ghz w/ Corsair H100i
      • Memory:
      • 16Gb Corsair Vengeance PC3-12800
      • Storage:
      • 120Gb Samsung 850 EVO, 60Gb Crucial M4 & 2TB Seagate
      • Graphics card(s):
      • EVGA 980 Ti Hybrid
      • PSU:
      • Coolermaster 550W Modular
      • Case:
      • Corsair 540 Air
      • Operating System:
      • Windows 10 x64
      • Monitor(s):
      • 2x 24" Dell U2314H
      • Internet:
      • Sky Fiber 80Mb/20Mb

    Re: Frames & Javascript redirect

    Jim you brilliant man.

    Failed to have the function call in the body. Silly me.

    Everything working now. Thank you all
    Diablo (Main PC): Corsair Air 540; Gigabyte Z77-D3H; i5 3570k @ 4.4Ghz; 16Gb Corsair Vengeance PC3-12000; 120Gb Samsung 840 EVO; EVGA 980 Ti Hybrid; 2x Dell U2414H; Windows 10 x64.
    Imperius (VM Server): 2x Intel 5640, 64Gb RAM, 2x1Tb, 6x Intel NIC, VMware ESX 5.5
    Tyrael (File Server): Synology DS410 w/ 4x HD154UI; 2Gb RAM; DSM 5.2

  15. #14
    Not a good person scaryjim's Avatar
    Join Date
    Jan 2009
    Location
    Gateshead
    Posts
    15,196
    Thanks
    1,230
    Thanked
    2,291 times in 1,874 posts
    • scaryjim's system
      • Motherboard:
      • Dell Inspiron
      • CPU:
      • Core i5 8250U
      • Memory:
      • 2x 4GB DDR4 2666
      • Storage:
      • 128GB M.2 SSD + 1TB HDD
      • Graphics card(s):
      • Radeon R5 230
      • PSU:
      • Battery/Dell brick
      • Case:
      • Dell Inspiron 5570
      • Operating System:
      • Windows 10
      • Monitor(s):
      • 15" 1080p laptop panel

    Re: Frames & Javascript redirect

    Don't be too hard on yourself, I've been designing websites for money for over 10 years and I still make those kinds of mistakes all the time! The trick is picking them up before anyone else notices

  16. #15
    Registered User
    Join Date
    May 2016
    Posts
    1
    Thanks
    0
    Thanked
    0 times in 0 posts

    Re: Frames & Javascript redirect

    hey there. I know this is an old post, but I have been having a problem redirecting my individual pages to my main frame pages.
    The problem I am having is that my browser will just go into a loop refreshing the page non stop.

    Here is the java script I have on my index.htm page

    <script language="javascript">
    var fname="top"; //MAIN CONTENT AREA FRAME **NAME**

    window.onload=function(){
    var d=document.location.search;
    if(d!='')top.frames[fname].document.location.href=d.substring(d.lastIndexOf('?')+1,d.length);
    }
    </script>


    here is my frames html

    <frameset cols="194,90%" framespacing="0" border="0" frameborder="0">
    <frame name="left" scrolling="no" noresize target="rtop" src="banner.htm">
    <frameset rows="81%,19%">
    <frame name="top" target="top" scrolling="auto" src="home.htm" noresize>
    <frame name="bottom" scrolling="no" noresize src="menu.htm" target="_self">
    </frameset>
    <noframes>
    <body>


    here is the java script I place on every other page on my site:

    <script language="javascript">
    if(self.location==top.location)self.location="index.htm?areas.htm";
    </script>


    now here is the thing.. If I change var fname="top"; to something else like 'bottom' or 'left' it will load the content in that frame, but when I have var fname="top"; it goes into an endless loop of refreshing and not loading the content at all.

    can anyone shed any light on what I am going wrong?

    Matt

  17. #16
    Senior Member
    Join Date
    Aug 2013
    Location
    North Wales
    Posts
    1,850
    Thanks
    165
    Thanked
    271 times in 202 posts
    • virtuo's system
      • Motherboard:
      • Gigabyte Aorus Master X570
      • CPU:
      • Ryzen 9 5950x
      • Memory:
      • 64Gb G.Skill TridentZ Neo 3600 CL16
      • Storage:
      • Sabrent 2TB PCIE4 NVME + NAS upon NAS upon NAS
      • Graphics card(s):
      • RTX 3090 FE
      • PSU:
      • Corsair HX850 80+ Platinum
      • Case:
      • Fractal Meshify 2 Grey
      • Operating System:
      • RedStar 3, Ubuntu, Win 10
      • Monitor(s):
      • Samsung CRG90 5140x1440 120hz
      • Internet:
      • PlusNet's best, but still poor, attempt

    Re: Frames & Javascript redirect

    Quote Originally Posted by matthewjames88 View Post
    hey there. I know this is an old post, but I have been having a problem redirecting my individual pages to my main frame pages.
    The problem I am having is that my browser will just go into a loop refreshing the page non stop.

    Here is the java script I have on my index.htm page

    <script language="javascript">
    var fname="top"; //MAIN CONTENT AREA FRAME **NAME**

    window.onload=function(){
    var d=document.location.search;
    if(d!='')top.frames[fname].document.location.href=d.substring(d.lastIndexOf('?')+1,d.length);
    }
    </script>


    here is my frames html

    <frameset cols="194,90%" framespacing="0" border="0" frameborder="0">
    <frame name="left" scrolling="no" noresize target="rtop" src="banner.htm">
    <frameset rows="81%,19%">
    <frame name="top" target="top" scrolling="auto" src="home.htm" noresize>
    <frame name="bottom" scrolling="no" noresize src="menu.htm" target="_self">
    </frameset>
    <noframes>
    <body>


    here is the java script I place on every other page on my site:

    <script language="javascript">
    if(self.location==top.location)self.location="index.htm?areas.htm";
    </script>


    now here is the thing.. If I change var fname="top"; to something else like 'bottom' or 'left' it will load the content in that frame, but when I have var fname="top"; it goes into an endless loop of refreshing and not loading the content at all.

    can anyone shed any light on what I am going wrong?

    Matt
    Try renaming your frame from "top" to something like "topframe" (I would expect "top" could cause problems as it's similar to a reserved name). I'd also take the "target" attributes off your frame elements, probably not causing a problem, but they won't do anything anyway.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. x264 video encoding benchmark
    By graysky in forum PC Hardware and Components
    Replies: 89
    Last Post: 24-02-2008, 01:54 PM
  2. IEEE Capture drops hundreds of frames after installing Pinnacle USB box.
    By Mabus in forum Help! Quick Relief From Tech Headaches
    Replies: 1
    Last Post: 16-09-2006, 10:10 PM
  3. Dual Graphics Cards -- Alternating frames
    By Artic_Kid in forum Graphics Cards
    Replies: 49
    Last Post: 16-12-2005, 03:05 PM
  4. redirect, bookmarks & javascript site bug
    By directhex in forum HEXUS Suggestions
    Replies: 1
    Last Post: 21-11-2005, 11:14 AM
  5. is this hype?9800 pro owners beware
    By CrapshoT in forum Graphics Cards
    Replies: 9
    Last Post: 16-10-2003, 02:45 PM

Posting Permissions

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