Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. JavaScript
  4. Link through javascript

Link through javascript

Scheduled Pinned Locked Moved JavaScript
helpquestionjavascripthtmltools
7 Posts 3 Posters 7 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    offroaderdan
    wrote on last edited by
    #1

    Experts, I have a problem which i need help with, I have a javascript page which will detect the users browser, if it is below a certain defined state another webpage will be displayed saying. Unfortunatly your web browser is not up to date. This has all been done however how do i link pages through javascript? i thought this would work however it doesn't

    document.write("<href='oops.html'>");

    I have also tried closing the javascript and opening a html tag (would look something like this)

    </script>

    <a href="../MWHAHA website/oops.html"></a>
    <script type="text/javascript">

    all i would like to do is open a html page if a statement is true or not. If anybody can help that would be great Cheers Dan

    D N 2 Replies Last reply
    0
    • O offroaderdan

      Experts, I have a problem which i need help with, I have a javascript page which will detect the users browser, if it is below a certain defined state another webpage will be displayed saying. Unfortunatly your web browser is not up to date. This has all been done however how do i link pages through javascript? i thought this would work however it doesn't

      document.write("<href='oops.html'>");

      I have also tried closing the javascript and opening a html tag (would look something like this)

      </script>

      <a href="../MWHAHA website/oops.html"></a>
      <script type="text/javascript">

      all i would like to do is open a html page if a statement is true or not. If anybody can help that would be great Cheers Dan

      D Offline
      D Offline
      daveyerwin
      wrote on last edited by
      #2

      location.replace('oops.html'); But, your scheme seems wrong. Exactly which browsers will you disallow, and for what reason?

      O 1 Reply Last reply
      0
      • D daveyerwin

        location.replace('oops.html'); But, your scheme seems wrong. Exactly which browsers will you disallow, and for what reason?

        O Offline
        O Offline
        offroaderdan
        wrote on last edited by
        #3

        Hi thanks for your reply! I will be disallowing browsers such as internet explorer which is < version 6 as my website will not function correctly in it. I tried the location.replace('oops.html') but nothing happened. The code i need something simular to this if interent explorer <6 then open url opps.html else do nothing In the javascript i cannot get the url to load the page. Thanks

        D 1 Reply Last reply
        0
        • O offroaderdan

          Hi thanks for your reply! I will be disallowing browsers such as internet explorer which is < version 6 as my website will not function correctly in it. I tried the location.replace('oops.html') but nothing happened. The code i need something simular to this if interent explorer <6 then open url opps.html else do nothing In the javascript i cannot get the url to load the page. Thanks

          D Offline
          D Offline
          daveyerwin
          wrote on last edited by
          #4

          putting this in head will redirect IE browsers less than 6 (google 'conditional comments') Commonly, the necessary features are checked and the page redirected if they are present leaving browsers which do not have desired features at current page, the current page will explain the problem to the user. Users with appropriate browsers will not see the current page because they will have been redirected. (google 'javascript feature testing') Also, if a necessary feature is missing from browser there is always a javascript work-around that will compensate, unless of course it's javascript thats missing. In that case it will not redirect! So leaving that browser on current page is good option.

          1 Reply Last reply
          0
          • O offroaderdan

            Experts, I have a problem which i need help with, I have a javascript page which will detect the users browser, if it is below a certain defined state another webpage will be displayed saying. Unfortunatly your web browser is not up to date. This has all been done however how do i link pages through javascript? i thought this would work however it doesn't

            document.write("<href='oops.html'>");

            I have also tried closing the javascript and opening a html tag (would look something like this)

            </script>

            <a href="../MWHAHA website/oops.html"></a>
            <script type="text/javascript">

            all i would like to do is open a html page if a statement is true or not. If anybody can help that would be great Cheers Dan

            N Offline
            N Offline
            NeverHeardOfMe
            wrote on last edited by
            #5

            location.href = 'newpage.html';

            D 1 Reply Last reply
            0
            • N NeverHeardOfMe

              location.href = 'newpage.html';

              D Offline
              D Offline
              daveyerwin
              wrote on last edited by
              #6

              NeverHeardOfMe wrote:

              location.href = 'newpage.html';

              The difference between location.href and location.replace is that location.href creates a new history entry on the visitor's browser while location.replace replaces the history entry. If the history entry is not replaced the back button will lead to the redirect page again causing 'redirection loop' which is usually undesirable and may have unwanted side effects.

              N 1 Reply Last reply
              0
              • D daveyerwin

                NeverHeardOfMe wrote:

                location.href = 'newpage.html';

                The difference between location.href and location.replace is that location.href creates a new history entry on the visitor's browser while location.replace replaces the history entry. If the history entry is not replaced the back button will lead to the redirect page again causing 'redirection loop' which is usually undesirable and may have unwanted side effects.

                N Offline
                N Offline
                NeverHeardOfMe
                wrote on last edited by
                #7

                TIL... to RTFM properly! I stand corrected... :thumbsup:

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups