How to navigate to new URL without new instance of browser

Discussion in 'Javascript' started by Paul E. Schoen, Sep 22, 2009.

  1. This is probably stupid simple, but I just want to run a script that
    navigates from the web page that has just been opened to another web page
    with a different URL. I would also like to have an alert appear for a short
    time stating that another web page is being opened. Here is my complete
    script (in links.htm):

    <SCRIPT LANGUAGE="JScript">
    <!--
    function Load_bsnlinks()
    {
    open("bsnlinks.htm", "NewWindow");
    }
    alert("Transferring to bsnlinks.htm");
    setTimeout(Load_bsnlinks, 3000);
    <!-- End Script -->
    </SCRIPT>

    If I use the alert, it seems to pause execution until the user clicks its
    OK button. Then the "links.htm" page loads, and after a short delay a new
    instance of the browser appears with the "bsnlinks.htm". But I want it to
    load in the original window, as if someone clicked on a link.

    Sorry if this is trivial, but I checked the FAQ and found only the open()
    function.

    Thanks,

    Paul
     
    Paul E. Schoen, Sep 22, 2009
    #1
    1. Advertising

  2. Paul E. Schoen

    SAM Guest

    Le 9/22/09 8:10 PM, Paul E. Schoen a écrit :
    > This is probably stupid simple, but I just want to run a script that
    > navigates from the web page that has just been opened to another web page
    > with a different URL. I would also like to have an alert appear for a short
    > time stating that another web page is being opened. Here is my complete
    > script (in links.htm):
    >
    > <SCRIPT LANGUAGE="JScript">
    > <!--
    > function Load_bsnlinks()
    > {
    > open("bsnlinks.htm", "NewWindow");
    > }
    > alert("Transferring to bsnlinks.htm");
    > setTimeout(Load_bsnlinks, 3000);
    > <!-- End Script -->
    > </SCRIPT>
    >
    > If I use the alert, it seems to pause execution until the user clicks its
    > OK button. Then the "links.htm" page loads, and after a short delay a new
    > instance of the browser appears with the "bsnlinks.htm". But I want it to
    > load in the original window, as if someone clicked on a link.
    >
    > Sorry if this is trivial, but I checked the FAQ and found only the open()
    > function.


    window.open() ! ( document.open() exists too)

    location = 'myNewOtherFile.htm';
    or (but I don't know the difference between both) :
    location.href = 'myNewOtherFile.htm';



    ===== Example 1:

    <script type=text/javascript">
    function Load_bsnlinks(theFile)
    {
    if(confirm('Do you accept the transfer to : '+theFile+'?'))
    setTimeout('location='+theFile, 1000);
    else alert('OK. Transfer aborted.');
    }
    </script>
    <button onclick="Load_bsnlinks('bsnlinks.htm')">
    bsn links
    </button>


    ===== Example 2:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <script type=text/javascript">
    if(confirm('Do you accept the transfer to : '+theFile+'?'))
    location = theFile;
    else alert('OK. Transfer aborted.');
    </script>
    <title>Untitled</title>
    </head>
    <body>
    <h1>hello</h1>
    <noscript>
    <p>You probably haven't your JavaScript enabled,<br>
    please click that <a href="bsnlinks.htm">link</a></p>
    </noscript>
    <p>You've chosen to stay here... and now what can we do ?</p>
    </body>
    </html>



    ===== Example 3 (without JS) :

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <meta http-equiv="refresh" content="3;bsnlinks.htm">
    <title>Untitled</title>
    </head>
    <body>
    <h1>refresh</h1>
    <p>You'll been soon redirected to : <tt>bsnlinks.htm</tt></p>
    <p>You may click that <a href="bsnlinks.htm">link</a></p>
    </body>
    </html>


    --
    sm
     
    SAM, Sep 22, 2009
    #2
    1. Advertising

  3. Thanks for all the alternative ways to automatically forward to another web
    page. I prefer the method using only HTML, so that Javascript need not be
    enabled. But the example provided just refreshed the original page at the
    specified interval. I found a more detailed example here:
    http://www.htmlcodetutorial.com/document/index_tagsupp_4.html

    Here is the final version that works for me (Note that URL= is required):

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <meta http-equiv="refresh" content="5; URL=bsnlinks.htm">
    <title>links.htm (old BSN links)</title>
    </head>
    <body>
    <h1 align="center"><B><FONT COLOR="#ff0000">This is the old links.htm
    page</font></h1>
    <p align='center'>You'll been soon redirected to :
    <tt>bsnlinks.htm</tt></p>
    <p align='center'>You may click: <a href="bsnlinks.htm">Go To New BSN
    Links</a></p>
    </body>
    </html>

    Here is a link to the actual web page:
    http://www.smart.net/~pstech/bsn/links.htm

    Paul
     
    Paul E. Schoen, Sep 23, 2009
    #3
  4. Paul E. Schoen

    Evertjan. Guest

    Paul E. Schoen wrote on 22 sep 2009 in comp.lang.javascript:

    > This is probably stupid simple, but I just want to run a script that
    > navigates from the web page that has just been opened to another web
    > page with a different URL. I would also like to have an alert appear
    > for a short time stating that another web page is being opened. Here
    > is my complete script (in links.htm):
    >
    > <SCRIPT LANGUAGE="JScript">


    this 'language' is last century's coding,
    and JScript is only the M$ name.

    use

    <script type='text/javascript'>


    > <!--


    same objection, do not use <--,
    there is no modern browser that requires it

    > function Load_bsnlinks()
    > {


    Crockford "Style matters" explains that having the open { on the same
    line is safer.

    function Load_bsnlinks() {


    > open("bsnlinks.htm", "NewWindow");


    windows.open() is slightly safer.

    "NewWindow" does not open a new window,
    but a window named 'NewWindow'.

    If you want to open a new window,
    use '_blank' or simply leave
    the target parameter empty or absent:

    windows.open('bsnlinks.htm');


    > }


    > alert("Transferring to bsnlinks.htm");


    javascript, being single threaded waits till the alert() is answered.

    > setTimeout(Load_bsnlinks, 3000);


    so the timout is not sensible.

    > <!-- End Script -->


    No need for that, see above

    > </SCRIPT>


    uppercase is alowesd, but why not echo the opening <script

    > If I use the alert, it seems to pause execution until the user clicks
    > its OK button.


    acording to specs.

    > Then the "links.htm" page loads, and after a short
    > delay a new instance of the browser appears with the "bsnlinks.htm".
    > But I want it to load in the original window, as if someone clicked on
    > a link.


    use:

    window.location.href = 'bsnlinks.htm';


    > Sorry if this is trivial, but I checked the FAQ and found only the
    > open() function.


    It helps if you read the specs, whose urls are offered in the FAQ.

    Do not use old and inappropriate scripts,
    unless you thouroughly understand them
    and alter them to the 21th century and to your needs.

    Try:

    =============================================
    <b>Transferring to bsnlinks.htm</b>
    <script type='text/javascript'>
    window.setTimeout("window.location.href='bsnlinks.htm'",3000);
    </script>
    =============================================

    Or do not use javascript at all:

    =============================================
    <meta http-equiv="refresh" content="3;url=bsnlinks.htm">
    <b>Transferring to bsnlinks.htm</b>
    =============================================



    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Sep 23, 2009
    #4
  5. Stefan Weiss wrote:
    > On 23/09/09 00:34, SAM wrote:
    >> Le 9/22/09 8:10 PM, Paul E. Schoen a écrit :
    >>> This is probably stupid simple, but I just want to run a script that
    >>> navigates from the web page that has just been opened to another web page
    >>> with a different URL. I would also like to have an alert appear for a short
    >>> time stating that another web page is being opened. Here is my complete
    >>> script (in links.htm):
    >>>
    >>> <SCRIPT LANGUAGE="JScript">
    >>> <!--
    >>> function Load_bsnlinks()
    >>> {
    >>> open("bsnlinks.htm", "NewWindow");
    >>> }
    >>> alert("Transferring to bsnlinks.htm");
    >>> setTimeout(Load_bsnlinks, 3000);
    >>> <!-- End Script -->
    >>> </SCRIPT>

    >
    > window.open() will always (try to) open a new window. If you want to
    > load a new document in the current window/tab, use the |window.location|
    > object.


    Only if that does not break (backward/forward) navigation.

    >> location = 'myNewOtherFile.htm';
    >> or (but I don't know the difference between both) :
    >> location.href = 'myNewOtherFile.htm';

    >
    > Browsers support assigning a URL string to the window.location object
    > directly; it has the same effect as assigning to its href property. The
    > latter is better style, IMO. The former was probably intended as a
    > shortcut, and can't be dropped now because it's too widely used. Anyway,
    > both assignments have "magical" side effects (=load a new document).


    The difference is, or at least was, that the `href' property of Location
    instances was/is "tainted", while the `location' property of Window
    instances was/is not. That means that the `location' property was/is not
    subject to the Same Origin Policy, thus could/can be used for accesses that
    the Policy would normally forbid.

    <http://docs.sun.com/source/816-6409-10/sec.htm#1021266>

    (Note: Nowadays [since JavaScript 1.4, and never in JScript or other
    implementations] those host objects are no longer part of the programming
    language but of the DOM implementation. However, that tainting was removed
    in JavaScript 1.2 is incorrect; instead, it appears to have been enabled by
    default for at least the Gecko DOM.)

    >> <script type="text/javascript">

    > [typo fixed]
    >
    > @Paul: This is the correct way to open a script tag.


    It is the _start tag_ of a script _element_. The element is _started_, not
    opened, and _ended_ (with an end tag), not closed. (When I started Web
    development, I did that one wrong, too. Some kind people pointed me to the
    Specification then.)

    <http://www.w3.org/TR/REC-html40/intro/sgmltut.html>

    > The language attribute is obsolete,


    No, it is _deprecated_ in HTML, which is different (declared for
    Transitional variants, not so for Strict variants). If it was *obsolete*
    already, the current HTML Specification (4.01) would not define it at all.
    IOW: the terms "deprecated" and "obsolete" must be set in relation to a
    specific version of a specific markup language.

    > language="JScript" will only work in Internet Explorer


    No, it is going to work in all MSHTML-based browsers, but probably not many
    others (so not in Gecko-based ones, like Firefox/Iceweasel).

    > (an unnecessary restriction in your case),


    Yes, it is at least unwise and of course invalid without the `type' attribute.

    > and element names are usually written in lower-case (today).


    ,-<http://www.flightlab.com/~joe/sgml/faq-not.txt>
    |
    | Q. How do I get the current element name in XSLT?
    |
    | A. That's element *type* name, dammit!

    It is not a requirement as element _type names_ are case-insensitive in
    HTML, but it helps compression (e.g., with `Transfer-Encoding: gzip', or on
    a compressed server filesystem) as lowercase letters are prevalent in
    Latin-based texts, thus usually compress better than equivalent uppercase
    letters. It also helps migration to XHTML where lowercase element type
    names and attribute names are required (which is what you might mean by
    referring to "today"; keep in mind though that XHTML support is still not
    prevalent in user agents -- most notably IE/MSHTML does not support it --,
    and that XHTML 2 development was recently reduced/suspended by W3C in favor
    of development of HTML 5.)

    > @Paul: A (not so minor) nitpick: lose the HTML comments inside your
    > script. The way you use them makes your HTML invalid,


    No, evidently it doesn't. The reason is that the content of the *HTML*
    `script' element is declared CDATA, not PCDATA. So it is not parsed (except
    of the `</' [ETAGO delimiter] which ends the element content). Just run it
    through <http://validator.w3.org/> to see for yourself.

    It would be syntactically invalid script and XHTML code, of course.

    > and the times where scripts had to be hidden from the browser are long gone.


    Definitely. HTML 3.2, which introduced the `script' element and mandates
    that user agents should hide the element's content dates back to 1997-01 CE.

    > <script type="text/javascript">
    > function loadBSNLinks () {
    > document.getElementById("linkMsg").style.display = "block";
    > window.setTimeout("window.location.href = 'bsnlinks.htm'", 1000);
    > }
    > </script>
    >
    > <button onclick="loadBSNLinks()">try it</button>
    >
    > <div id="linkMsg" style="display:none">
    > Transferring to bsnlinks.htm
    > </div>
    >
    >
    > Set the styles for the linkMsg element so that it appears as a pseudo-alert.


    The whole idea of the OP is utter nonsense already, and should not be
    supported by posting bogus solutions. There has been no real problem
    presented to be solved to begin with, and the Web is *haunted* by the
    results of such inept attempts at seemingly improving usability, thereby
    effectively reducing it, already.

    In this case, there is no good reason to force the user to wait one second
    before navigating elsewhere. Do you really think they bought a fast
    computer to let it show someone's wait message?


    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Sep 23, 2009
    #5
  6. Stefan Weiss wrote:
    > On 23/09/09 11:51, Thomas 'PointedEars' Lahn wrote:
    >> Stefan Weiss wrote:
    >>> language="JScript" will only work in Internet Explorer

    >> No, it is going to work in all MSHTML-based browsers, but probably not many
    >> others (so not in Gecko-based ones, like Firefox/Iceweasel).

    >
    > AFAIK, JScript lives in jscript.dll, not mshtml.dll.


    Regardless, the layout engine's markup parser is required in order to
    recognize code that should be passed to a script engine. And I have yet to
    see a distribution of MSHTML that comes without JScript support. While that
    should go without saying, consider language="VBScript" and think about what
    would be necessary in order to invoke vbscript.dll in a Web browser
    (component) then.

    >>> Set the styles for the linkMsg element so that it appears as a pseudo-alert.

    >> The whole idea of the OP is utter nonsense already, and should not be
    >> supported by posting bogus solutions. There has been no real problem
    >> presented to be solved to begin with, and the Web is *haunted* by the
    >> results of such inept attempts at seemingly improving usability, thereby
    >> effectively reducing it, already.
    >>
    >> In this case, there is no good reason to force the user to wait one second
    >> before navigating elsewhere. Do you really think they bought a fast
    >> computer to let it show someone's wait message?

    >
    > We don't know why he wanted to display the message. Maybe there's a good
    > reason for it, maybe there isn't.


    The OP, his history here, his script-kiddy-ish wording and source code is a
    strong indication to some that there is not a good reason, just a desire to
    do something fancy.

    > This group is about JavaScript, not UI design;


    This newsgroup is about providing the best solutions possible when the
    problem is related to client-side scripting, and about discussing possible
    mistakes when looking for one. And, if I may say so, as a newbie here you
    are not really in a position to make an informed judgment about what is and
    is not on-topic here. Regardless, the FAQ and archives provide enough hints.

    > I merely provided a working version of his earlier attempt.


    For suitable values of "working".


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrman
     
    Thomas 'PointedEars' Lahn, Sep 23, 2009
    #6
  7. Thomas 'PointedEars' Lahn wrote:
    > Stefan Weiss wrote:
    >> This group is about JavaScript, not UI design;

    >
    > This newsgroup is about providing the best solutions possible when the
    > problem is related to client-side scripting,


    JFTR: ... and server-side ECMAScript-based scripting of course, but
    ECMAScript implementations are undoubtedly prevalent on the client side.

    > and about discussing possible mistakes when looking for one. And, if I
    > may say so, as a newbie here you are not really in a position to make an
    > informed judgment about what is and is not on-topic here. Regardless,
    > the FAQ and archives provide enough hints.
    > [...]



    PointedEars
    --
    Anyone who slaps a 'this page is best viewed with Browser X' label on
    a Web page appears to be yearning for the bad old days, before the Web,
    when you had very little chance of reading a document written on another
    computer, another word processor, or another network. -- Tim Berners-Lee
     
    Thomas 'PointedEars' Lahn, Sep 23, 2009
    #7
  8. "Thomas 'PointedEars' Lahn" <> wrote in message
    news:...
    > Stefan Weiss wrote:
    >> On 23/09/09 11:51, Thomas 'PointedEars' Lahn wrote:


    >>> The whole idea of the OP is utter nonsense already, and should not be
    >>> supported by posting bogus solutions. There has been no real problem
    >>> presented to be solved to begin with, and the Web is *haunted* by the
    >>> results of such inept attempts at seemingly improving usability,
    >>> thereby
    >>> effectively reducing it, already.
    >>>
    >>> In this case, there is no good reason to force the user to wait one
    >>> second
    >>> before navigating elsewhere. Do you really think they bought a fast
    >>> computer to let it show someone's wait message?

    >>
    >> We don't know why he wanted to display the message. Maybe there's a good
    >> reason for it, maybe there isn't.

    >
    > The OP, his history here, his script-kiddy-ish wording and source code is
    > a
    > strong indication to some that there is not a good reason, just a desire
    > to
    > do something fancy.


    I am admittedly a newbie in JavaScript and it is only a very small part of
    the skill set I use for my professional and personal needs. My purpose for
    this was to fix a broken link that someone apparently has on their website,
    which points to my old links.htm page rather than the newer bsnlinks.htm.
    So I wanted to alert the user to the fact that this link was no longer
    valid, and then forward them to the correct page. If I did not include a
    delay, the new web page would appear almost immediately, and they would not
    know that their link was broken. I did not know that this could be done
    even better using just the HTML META refresh method, which does not require
    JavaScript at all.

    I am grateful to those who pointed me in the right direction so I could
    provide the best solution. I am not looking to do anything fancy, although
    it is good to have the knowledge to do so. But I do feel that it is
    disrespectful and supercilious of you to make the assumptions and
    accusations above. You may be an expert in this field, but your social
    skills could use a little polish.

    Paul
     
    Paul E. Schoen, Sep 23, 2009
    #8
  9. Paul E. Schoen wrote:
    > I am admittedly a newbie in JavaScript and it is only a very small part of
    > the skill set I use for my professional and personal needs. My purpose for
    > this was to fix a broken link that someone apparently has on their website,
    > which points to my old links.htm page rather than the newer bsnlinks.htm.


    So you set up a *server-side* redirect. You definitely do not use scripting
    or HTML or any other client-side means for that.

    > So I wanted to alert the user to the fact that this link was no longer
    > valid, and then forward them to the correct page. If I did not include a
    > delay, the new web page would appear almost immediately, and they would not
    > know that their link was broken. I did not know that this could be done
    > even better using just the HTML META refresh method, which does not require
    > JavaScript at all.


    How can it be better when it breaks the Back button

    > [Rubbish snipped] You may be an expert in this field, but your social
    > skills could use a little polish.


    Pot, kettle, black. This is _not_ a support forum.

    <http://jibbering.com/faq/#posting> pp.


    I'd say "Score adjusted" if that was not already done.

    PointedEars
    --
    var bugRiddenCrashPronePieceOfJunk = (
    navigator.userAgent.indexOf('MSIE 5') != -1
    && navigator.userAgent.indexOf('Mac') != -1
    ) // Plone, register_function.js:16
     
    Thomas 'PointedEars' Lahn, Sep 25, 2009
    #9
  10. Paul E. Schoen

    SAM Guest

    Le 9/25/09 4:08 PM, Thomas 'PointedEars' Lahn a écrit :
    > Paul E. Schoen wrote:
    >> I am admittedly a newbie in JavaScript and it is only a very small part of
    >> the skill set I use for my professional and personal needs. My purpose for
    >> this was to fix a broken link that someone apparently has on their website,
    >> which points to my old links.htm page rather than the newer bsnlinks.htm.

    >
    > So you set up a *server-side* redirect. You definitely do not use scripting
    > or HTML or any other client-side means for that.


    Non, je ne suis pas d'accord ! !

    I don't agree with you, even if this possibility could be studied and
    used, supposing the "webmaster" is allowed to access to the server.
    Does that will correct the bookmark of the visitor ?
    (if he came on that no more existing page, wasn't it because he used a
    wrong bookmark? I think to offer him a possibility to know that this
    bookmark is wrong and to correct it is not a so bad idea).

    >> So I wanted to alert the user to the fact that this link was no longer
    >> valid, and then forward them to the correct page. If I did not include a
    >> delay, the new web page would appear almost immediately, and they would not
    >> know that their link was broken. I did not know that this could be done
    >> even better using just the HTML META refresh method, which does not require
    >> JavaScript at all.

    >
    > How can it be better when it breaks the Back button


    pfffft !

    The guy certainly came on this page hitting one of his bookmarks that is
    out of date, what he has to do with a back button ?

    Anyway I do not understand your idea of no more back button.
    The back-button seems to jump over the refreshing page, is it really
    serious doctor ?


    >> [Rubbish snipped] You may be an expert in this field, but your social
    >> skills could use a little polish.

    >
    > Pot, kettle, black. This is _not_ a support forum.


    Yes, it can be, why not.
    Or is it forbidden in a rule, or in a law, somewhere?

    --
    sm
     
    SAM, Sep 25, 2009
    #10
  11. "SAM" <> wrote in message
    news:4abd2b27$0$17743$...
    > Le 9/25/09 4:08 PM, Thomas 'PointedEars' Lahn a écrit :
    >> Paul E. Schoen wrote:
    >>> I am admittedly a newbie in JavaScript and it is only a very small part
    >>> of the skill set I use for my professional and personal needs. My
    >>> purpose for this was to fix a broken link that someone apparently has
    >>> on their website, which points to my old links.htm page rather than the
    >>> newer bsnlinks.htm.

    >>
    >> So you set up a *server-side* redirect. You definitely do not use
    >> scripting
    >> or HTML or any other client-side means for that.

    >
    > Non, je ne suis pas d'accord ! !
    >
    > I don't agree with you, even if this possibility could be studied and
    > used, supposing the "webmaster" is allowed to access to the server.
    > Does that will correct the bookmark of the visitor ?
    > (if he came on that no more existing page, wasn't it because he used a
    > wrong bookmark? I think to offer him a possibility to know that this
    > bookmark is wrong and to correct it is not a so bad idea).


    That's what I thought. I could figure out how to make a server side
    "shortcut" so that the links.htm redirects to bsnlinks.htm, but that won't
    do what I want and it involves getting involved with Linux.


    >>> So I wanted to alert the user to the fact that this link was no longer
    >>> valid, and then forward them to the correct page. If I did not include
    >>> a delay, the new web page would appear almost immediately, and they
    >>> would not know that their link was broken. I did not know that this
    >>> could be done even better using just the HTML META refresh method,
    >>> which does not require JavaScript at all.

    >>
    >> How can it be better when it breaks the Back button

    >
    > pfffft !
    >
    > The guy certainly came on this page hitting one of his bookmarks that is
    > out of date, what he has to do with a back button ?
    >
    > Anyway I do not understand your idea of no more back button.
    > The back-button seems to jump over the refreshing page, is it really
    > serious doctor ?


    When I tested it, the back button goes to the links.htm and then redirects
    back to the bsnlinks.htm. If I click it twice it goes to the page before
    that. So it certainly has not broken the back button. It does *exactly*
    what I wanted it to do.


    >>> [Rubbish snipped] You may be an expert in this field, but your social
    >>> skills could use a little polish.

    >>
    >> Pot, kettle, black. This is _not_ a support forum.

    >
    > Yes, it can be, why not.
    > Or is it forbidden in a rule, or in a law, somewhere?


    Of course, if I knew that this could be done without script using HTML, I
    would have asked on the appropriate forum. And IMHO newsgroups have always
    been for support. Most of the OPs are from people having problems and they
    get guidance and expert advice. Followup posts provide information or
    become a discussion. I was grateful for the help offered and I showed the
    final solution. All done with proper netiquette. And my social skills are
    quite healthy, unlike those of the resident Vulcan who purposefully
    represses any human feelings or emotions. PBK indeed. I say, judge not,
    lest ye be judged...

    Paul
     
    Paul E. Schoen, Sep 26, 2009
    #11
  12. SAM kirjoitti:

    > I don't agree with you, even if this possibility could be studied and
    > used, supposing the "webmaster" is allowed to access to the server.


    No matter. The Rule is: if there is the option of doing a redirect
    server side, then it remains as the only option.

    > Does that will correct the bookmark of the visitor ?


    It does not have to. Bookmark or link, does not matter, works like a charm.

    > (if he came on that no more existing page, wasn't it because he used a
    > wrong bookmark? I think to offer him a possibility to know that this
    > bookmark is wrong and to correct it is not a so bad idea).


    Well, a non existing page (broken URL) is no option at all. What about a
    page stating that somebody messed up with a link to the new location?

    > The guy certainly came on this page hitting one of his bookmarks that is
    > out of date, what he has to do with a back button ?


    Maybe he would want to navigate backwards through history? Why do you
    think the browsers provide this functionality?

    > Anyway I do not understand your idea of no more back button.
    > The back-button seems to jump over the refreshing page, is it really
    > serious doctor ?


    Which browser, which page? Anyways it's serious alright and it's called
    breaking the back button. See:

    http://www.useit.com/alertbox/990530.html

    Sum: immediate or relatively fast redirects that create a new history
    entry are at best annoying, at worst disorienting.

    To get a little bit on topic: if server side is not an option,
    window.location.replace would be better than meta refresh, as it does
    not create a new history entry.

    --
    Best wishes,
    Osmo
     
    Osmo Saarikumpu, Sep 26, 2009
    #12
  13. Osmo Saarikumpu wrote:
    > SAM kirjoitti:
    >> I don't agree with you, even if this possibility could be studied and
    >> used, supposing the "webmaster" is allowed to access to the server.

    >
    > No matter. The Rule is: if there is the option of doing a redirect
    > server side, then it remains as the only option.


    Whereas redirect should include rewrite here, don't you think?

    >> Does that will correct the bookmark of the visitor ?

    >
    > It does not have to. Bookmark or link, does not matter, works like a charm.


    And the redirection can be done in a way -- even transparently with regard
    to the displayed URI -- that the user is notified on the resource they are
    redirected to that their bookmark or link should be updated. BTDT.

    >> (if he came on that no more existing page, wasn't it because he used a
    >> wrong bookmark? I think to offer him a possibility to know that this
    >> bookmark is wrong and to correct it is not a so bad idea).

    >
    > Well, a non existing page (broken URL) is no option at all. What about a
    > page stating that somebody messed up with a link to the new location?


    Actually, HTTP intentionally provides the 410 Gone response status code for
    that, so it is an option (but obviously seldom the best one). Apache
    supports that so that you can redirect to a document which could explain why
    the resource is gone (`ErrorDocument 410 gone-for-good', `Redirect gone
    foo.html'). This should be reserved for exceptional cases, though.

    > To get a little bit on topic: if server side is not an option,
    > window.location.replace would be better than meta refresh, as it does
    > not create a new history entry.


    True, but of course it would require sufficient client-side script and DOM
    support. Immediate redirect for one group of users and another one forced
    to click a link again does not sound very accessible to me. By contrast,
    the server-side approach works everywhere and always.


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann
     
    Thomas 'PointedEars' Lahn, Sep 26, 2009
    #13
  14. Paul E. Schoen wrote:
    > I could figure out how to make a server side
    > "shortcut" so that the links.htm redirects to bsnlinks.htm, but that won't
    > do what I want and it involves getting involved with Linux.


    Not necessarily. It involves getting to know the server that you are using,
    of course (probably Apache). You should consider that to be a good thing as
    you could be making the next step in the learning curve. What exactly are
    you afraid of?

    > When I tested it, the back button goes to the links.htm and then redirects
    > back to the bsnlinks.htm.


    And you think that is acceptable to a user, to navigate somewhere without
    being asked? Think again.

    > If I click it twice it goes to the page before that.


    It depends on how fast your visitors can click twice. Surely you can see that.

    > So it certainly has not broken the back button. It does *exactly*
    > what I wanted it to do.


    In the browsers that you have tested with, which were ... one, Internet
    Explorer on Microsoft Windows? Test it in Opera, where support for this
    proprietary feature can be disabled per user preference (and isn't it
    disabled by default there, Lasse?). It stands to reason that other browsers
    are going to or have already adopted setting the corresponding user
    preference, or that there are extensions to augment browsers with that behavior.

    >>>> [Rubbish snipped] You may be an expert in this field, but your social
    >>>> skills could use a little polish.
    >>> Pot, kettle, black. This is _not_ a support forum.

    >> Yes, it can be, why not.
    >> Or is it forbidden in a rule, or in a law, somewhere?

    >
    > Of course, if I knew that this could be done without script using HTML,


    But it cannot, and should not be done with any client-side means either.
    The earlier you understand that, the earlier you are going to stop being
    considered just a script-kiddie as you will be publishing a quality Web
    site that *really* benefits your visitors (and in the end, you).

    <http://www.w3.org/QA/Tips/>

    (You should follow the third link in the list, but consider all of them.)


    PointedEars
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
     
    Thomas 'PointedEars' Lahn, Sep 26, 2009
    #14
  15. REPOST :

    In comp.lang.javascript message <>, Fri,
    25 Sep 2009 16:08:41, Thomas 'PointedEars' Lahn <>
    posted:
    >
    >> [Rubbish snipped] You may be an expert in this field, but your social
    >> skills could use a little polish.


    A gross underestimate.

    >Pot, kettle, black. This is _not_ a support forum.


    It is what the majority of its users want it to be; that does not
    include you. Please emulate your older namesake.

    (Vg ehaf vagb gur Euvar, nppbeqvat gb Jvxvcrqvn.)

    --
    (c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
    Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
    <URL:http://www.merlyn.demon.co.uk/problems.htm#Ans>
     
    Dr J R Stockton, Sep 26, 2009
    #15
  16. Paul E. Schoen

    SAM Guest

    Le 9/26/09 7:24 PM, Osmo Saarikumpu a écrit :
    > SAM kirjoitti:
    >
    >> I don't agree with you, even if this possibility could be studied and
    >> used, supposing the "webmaster" is allowed to access to the server.

    >
    > No matter. The Rule is: if there is the option of doing a redirect
    > server side, then it remains as the only option.


    No, seriously, in regard to the purpose : tell the page has moved
    I can't follow you on this way '*the* rule is'.

    >> Does that will correct the bookmark of the visitor ?

    >
    > It does not have to. Bookmark or link, does not matter, works like a charm.


    I don't say the contrary, however
    I've a lot of bookmarks like that pointing now nowhere or (by chance ?)
    redirected to the 404 and some of them to a page more useful.
    In case my wrong old bookmark is immediately redirected to the correct
    new page, my own reference is still false. If I'm not too attentive I'll
    not think to change this bookmark. (I say 'I' but, he, we ...)

    >> (if he came on that no more existing page, wasn't it because he used a
    >> wrong bookmark? I think to offer him a possibility to know that this
    >> bookmark is wrong and to correct it is not a so bad idea).

    >
    > Well, a non existing page (broken URL) is no option at all. What about a
    > page stating that somebody messed up with a link to the new location?


    Sorry, here my english is too poor to be sure of what you mean.

    >> The guy certainly came on this page hitting one of his bookmarks that
    >> is out of date, what he has to do with a back button ?

    >
    > Maybe he would want to navigate backwards through history? Why do you
    > think the browsers provide this functionality?


    I don't know, since browsers have tabs I rarely use yet that. ;-)

    >> Anyway I do not understand your idea of no more back button.
    >> The back-button seems to jump over the refreshing page, is it really
    >> serious doctor ?

    >
    > Which browser, which page? Anyways it's serious alright and it's called
    > breaking the back button. See:


    I tested with pages made for that and Firefox, at the back and the
    recommencement forward, has purely ignored the refresh page which
    nevertheless had a timeout.
    This time I tried with :
    - Safary : don't jump over the refresh page on back/forward buttons,
    passing back in both direction it doesn't load the file,
    just display it and without refreshing.
    (I think now IE does it, not reload the page where we come back)
    - Opera : does exactly as Firefox

    > http://www.useit.com/alertbox/990530.html


    In points 1 and 2 they speak about :
    - refresh *without* delay, that was not retained here
    - new window, which has not more been mentioned here.
    (and then ? that doesn't close the previous one, no ?)
    - that history of back button breaking history
    seems to me the history of the past
    (if it ever was true for browsers !IE)
    Following points : OK

    > Sum: immediate or relatively fast redirects that create a new history
    > entry are at best annoying, at worst disorienting.


    That doesn't seem to create a *new* history in browsers I use.

    > To get a little bit on topic: if server side is not an option,
    > window.location.replace would be better than meta refresh, as it does
    > not create a new history entry.


    OK, perhaps to keep in mind.

    --
    sm
     
    SAM, Sep 26, 2009
    #16
  17. Hans-Georg Michna wrote:
    > On Fri, 25 Sep 2009 20:17:14 -0400, Paul E. Schoen wrote:
    >> That's what I thought. I could figure out how to make a server side
    >> "shortcut" so that the links.htm redirects to bsnlinks.htm, but that won't
    >> do what I want and it involves getting involved with Linux.

    >
    > It also means getting involved with the Apache rewrite module on
    > many servers,


    FUD. Simple redirects, which suffice for this case, can be done with the
    `Redirect' and `RedirectMatch' directives.

    > and that thing is about the ugliest piece of code I know.


    How fortunate then that you really don't know what you are talking about.

    > And I do know, my own Apache rewrite scripts are kind of
    > long and rather complex.


    How interesting, given that URL rewrite does not require any kind of script;
    the most simple case requires only two directives,

    RewriteEngine On
    RewriteRule ...

    > Can't say that I really like that thing.


    Evidently because you are using it wrong.

    > Pro meta redirect ...


    On what grounds? That it was better supported, that was more accessible,
    that it was more flexible than server-side redirection? Because *none* of
    that applies.

    > I keep hearing this advice, don't use the meta redirect in HTML,
    > use server redirects instead. But that advice is unrealistic
    > even for me, although I do have root access to my server.


    Your apparent inability to learn does not mean all other people must be
    equally stupid.

    > It is just too awkward to fiddle with Apache conf files on a running
    > server,


    FUD. The responsible Web developer tests on a local Web server with similar
    configuration than the remote one, and modifies the remote server
    configuration (with .htaccess or different) only after the tests have showed
    that the new configuration works. Then again, the responsible developer,
    after doing so several times, is wise enough to implement changes on the
    server-side without testing, without fouling up the server configuration.

    > And, of course, it can also be done in JavaScript.


    Apparently you have not paid attention. That thesis has already been
    disproved for the general case, the Web.


    PointedEars
    --
    Danny Goodman's books are out of date and teach practices that are
    positively harmful for cross-browser scripting.
    -- Richard Cornford, cljs, <cife6q$253$1$> (2004)
     
    Thomas 'PointedEars' Lahn, Sep 27, 2009
    #17
  18. "Hans-Georg Michna" <> wrote in message
    news:...
    > On Fri, 25 Sep 2009 20:17:14 -0400, Paul E. Schoen wrote:
    >
    >>That's what I thought. I could figure out how to make a server side
    >>"shortcut" so that the links.htm redirects to bsnlinks.htm, but that
    >>won't
    >>do what I want and it involves getting involved with Linux.

    >
    > It also means getting involved with the Apache rewrite module on
    > many servers, and that thing is about the ugliest piece of code
    > I know. And I do know, my own Apache rewrite scripts are kind of
    > long and rather complex. Can't say that I really like that
    > thing.


    I really don't have the skills to mess around with server side scripts and
    I am not sufficiently motivated to delve into that. I looked at Perl and
    that seemed daunting enough to stay away. And I don't know how to implement
    the `Redirect' and `RedirectMatch' directives as suggested by TPE, or
    'RewriteEngine On' and 'RewriteRule ...'

    > Pro meta redirect ...
    >
    > I keep hearing this advice, don't use the meta redirect in HTML,
    > use server redirects instead. But that advice is unrealistic
    > even for me, although I do have root access to my server. It is
    > just too awkward to fiddle with Apache conf files on a running
    > server, possibly blocking whole web sites because of a minuscule
    > mistake, not to mention web site operators who have no access to
    > the conf files.
    >
    > The meta redirects are exactly what most small-scale operators
    > want and need. I believe they are a continuous favorite, whether
    > we like it or not.


    The META refresh method works exactly as I wish, at least for IE7. In
    Firefox the page with the meta forwarding seems to be skipped in the
    history and the back button just skips over it. That is also perfectly
    acceptable behavior. This entire discussion is quite academic anyway, as
    this page is on a website that I only maintain for historical purposes, and
    I only knew about the incorrect link because someone emailed me that a link
    on that page was broken. If you care to see the website, go to
    www.bsn1.org, and the link there points to bsnlinks.htm. There may be
    another website or someone may have stored a favorites URL with the old
    http://www.smart.net/~pstech/bsn/links.htm


    > And, of course, it can also be done in JavaScript.


    But that means the user must have JavaScript enabled and probably would
    need to accept running scripts on the page, which they may not want to do
    because of security risks. I really though this thread would end when I
    accepted the advice to use the META refresh redirection as my best option.
    Leave it to TPE to find fault with it.

    Thanks for the educational discussion and support of the method I chose as
    most expedient.

    Paul
     
    Paul E. Schoen, Sep 27, 2009
    #18
  19. Richard Cornford kirjoitti:

    > On IE, under 'Internet Options' -> 'Security tab' -> (Any/All zone(es))
    > -> Custom Level... -> 'Miscellaneous' section, there is an entry entitle
    > "Allow META REFRESH" with the options "Enable" and "Disable". So META
    > refresh is something else that can be disabled for 'security reasons'.
    > And I would bet that META refresh does not 'work' "exactly as I wish" on
    > IE 7 (or any other version) when it is disabled.


    And Opera (at least my v. 9) has an option to enable/disable "automatic
    redirection" (Preferences --> Advanced --> Network), which affects only
    meta refreshes (not JS location replacement).

    --
    Best wishes,
    Osmo
     
    Osmo Saarikumpu, Sep 28, 2009
    #19
  20. Osmo Saarikumpu wrote:
    > Richard Cornford kirjoitti:
    >> On IE, under 'Internet Options' -> 'Security tab' -> (Any/All zone(es))
    >> -> Custom Level... -> 'Miscellaneous' section, there is an entry entitle
    >> "Allow META REFRESH" with the options "Enable" and "Disable". So META
    >> refresh is something else that can be disabled for 'security reasons'.
    >> And I would bet that META refresh does not 'work' "exactly as I wish" on
    >> IE 7 (or any other version) when it is disabled.

    >
    > And Opera (at least my v. 9) has an option to enable/disable "automatic
    > redirection" (Preferences --> Advanced --> Network), which affects only
    > meta refreshes (not JS location replacement).


    That's what I meant :)

    As you are an Opera user: I'm curious, was it disabled by default?


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$>
     
    Thomas 'PointedEars' Lahn, Sep 28, 2009
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dan Hinsley
    Replies:
    3
    Views:
    622
    Dan Hinsley
    Nov 27, 2004
  2. =?Utf-8?B?cmFq?=
    Replies:
    0
    Views:
    1,502
    =?Utf-8?B?cmFq?=
    Apr 12, 2005
  3. Arjen

    Setting the navigate URL

    Arjen, Jun 9, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    4,990
    Arjen
    Jun 9, 2005
  4. guoqi zheng
    Replies:
    3
    Views:
    750
    Nathan Sokalski
    May 29, 2006
  5. Mark Lindberg

    navigate URL isn't working in treeview

    Mark Lindberg, Dec 15, 2003, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    228
    Mark Lindberg
    Dec 15, 2003
Loading...

Share This Page