Detecting the Protocol of a Link

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Unregistered

    #1

    Detecting the Protocol of a Link


    I'm making an Intranet site for someone who is not very familiar wit
    making websites, thus I would like to make it as simple as possible fo
    her when she needs to update it.

    The intranet site uses frames - one menu frame that is always present
    and one frame into which the content is loaded. The intranet sit
    features many, many links to both internal and external pages - i
    internal pages within the intranet and external pages on the interne
    (http://)

    What I would like to do is make it so that if a link is internal, th
    content will load into the content frame and the menu frame will remai
    at the side, but if the link is external, it will load the target int
    the entire browser window. Using HTML, this would simply be a matter o
    stating the href and then target="content _frame" for internal pages o
    target="_top" for external pages.

    But, like I said, I am making this site for someone who is not familia
    with linking targets and even if I told her to define the targe
    whenever she makes a link, she'd probably forget or get confused an
    then wonder why external pages are loading with the intranet menu fram
    still present or why intranet pages are loading with no menu at th
    side!

    While I have good experience with HTML, I am fairly new to JavaScript
    which is why I am here asking for help.

    I understand that Javascript can detect the protocol of a link,
    believe you would use "link.protocol" . In basic terms, what I woul
    like to do is:

    if link.protocol = "http://" then target="_top" els
    target="content _frame"

    But since I'm not familiar with the precise way of coding JavaScript,
    would just like some help with transforming this into correc
    JavaScript code so that it will work.

    Thanks for taking the time to read this and for any help you can give

    Unregistered
    -----------------------------------------------------------------------
    Posted via http://www.forum4designers.co
    -----------------------------------------------------------------------
    View this thread: http://www.forum4designers.com/message44568.htm

  • Martin Honnen

    #2
    Re: Detecting the Protocol of a Link



    Unregistered wrote:
    [color=blue]
    > I'm making an Intranet site for someone who is not very familiar with
    > making websites, thus I would like to make it as simple as possible for
    > her when she needs to update it.
    >
    > The intranet site uses frames - one menu frame that is always present,
    > and one frame into which the content is loaded. The intranet site
    > features many, many links to both internal and external pages - ie
    > internal pages within the intranet and external pages on the internet
    > (http://)[/color]

    But doesn't the intranet use the HTTP protocol too? Or are you loading
    pages locally via file: urls?

    [color=blue]
    > I understand that Javascript can detect the protocol of a link, I
    > believe you would use "link.protocol" . In basic terms, what I would
    > like to do is:
    >
    > if link.protocol = "http://" then target="_top" else
    > target="content _frame"
    >
    > But since I'm not familiar with the precise way of coding JavaScript, I
    > would just like some help with transforming this into correct
    > JavaScript code so that it will work.[/color]

    If your intranet pages are loaded from the file system then
    <a onclick="if (this.protocol == 'http:') {
    this.target = '_top';
    }
    return true;"
    for your links will do
    --

    Martin Honnen
    http://JavaScript.FAQTs.com/

    Comment

    Working...