logo

Meeting Base Targets

When designing for Kiosk mode the page you design is the whole application as far as the user's concerned. The fact that it's inside a browser is irrelevant. A problem with this is the need to make sure the user stays within the confines of the application. Imagine a user clicks a link to an external website. This site takes over the whole screen and becomes the application. The user is stuck. There only hope of return is knowing that the backspace button might take them there.

To get round this we need to make sure all external links open in a separate window. How can we do this though? How do we know which links are "external"? If content of the app is contributed by the user we have little control over their links. Well, one way of doing it is to tackle it from a different angle. Remember my article called What to base your links on? We can use the same Base tag to force all links to open in a certain window. Here's the tag that you'd add to the head:

<base target="_blank" />

Now, all links will open in a fresh window. But, I here you thinking, that's not what we want. What about our own links that should stay inside the application? Well, we need to add the target attribute to them:

<a href="internal?Open" target="_self">Internal Link</a>

This means that Domino Views need to be treated as HTML so you can create your own links with the target attribute.

I know what you're thinking. This is right royal pain. True. But, unless I'm mistaken, there's no other way of doing it...

Comments

    • avatar
    • YoGi
    • Wed 27 Jul 2005 06:29 AM

    well you may use non-html domino views, just deactivate the "show values in column as links" and made your owns (ie : "[<a href='"+@text(@documentuniqueid)+"?opendocument' target='_self'>"+document_title+"</a>]", but i'm sure you've already thought about that. or didn't i understood your problem ?

    • avatar
    • IanB
    • Wed 27 Jul 2005 06:55 AM

    Surely it would be easier to treat external links to the special target treatment, as they would be the exception?

    I know we shouldn't use javascript but could you not iterate through all <a> tags in the page and check for the presence of external links and then add target-"_blank" to the innerhtml?

    • avatar
    • Chad S
    • Wed 27 Jul 2005 07:17 AM

    IanB is right, why not use javascript? There's code at

    {Link}

    that will accomplish it.

    • avatar
    • Jake Howlett
    • Wed 27 Jul 2005 10:38 AM

    You right YoGi, that would do the trick too.

    I don't want to use JavaScript really as I always see this as hcaking the page. I'd much rather control it all from the server and the actual HTML. Far less to go wrong.

    • avatar
    • Jorge Coelho
    • Wed 27 Jul 2005 11:40 AM

    Could you just use a different base tag for your view templates? If your view will only contain internal links, why not just create a different base tag, which will require less work everytime you create a view?

    • avatar
    • Jake Howlett
    • Wed 27 Jul 2005 11:46 AM

    Good point Jorge. Yes I could. Hadn't thought of that. Cheers.

  1. I confess, the reason I wrote the code that is linked above is that I am a very lazy person. I got tired of putting target="_blank" on all my external links. The kewl thing about the code is that I no longer have to worry about mistakenly setting the wrong target. Plus, it actually decreases the amount of HTML that is downloaded. What more can a lazy person ask for????

    Sean----

    • avatar
    • Tom
    • Wed 27 Jul 2005 03:59 PM

    Hi Jake,

    I think we could distinguish external links from internal ones by looking for "http:\\", as external links are absolute links, what do you think?

    I know so we'd use Javascript...why not really.

    • avatar
    • IanB
    • Wed 27 Jul 2005 05:09 PM

    following on, I've had another idea.

    have <base target="_blank" /> in the header.

    then wrap whatever element contains links you [i]know[/i] are internal in <base target="_self"> </base>.

    Oh...is that what jorge meant 8-(

  2. I don't see why you think the use of Javascript is like "hacking" a page. I think this is a situation when javascript is BEST suited for the job, mainly since the target attribute has been phased out of (X)HTML standards, but IS still part of the DOM standards.

  3. @IanB - That was my first choice, but there are 2 problems with that solution. The BASE tag does not have a closing tag and you are only allowed to have one BASE tag per page.

    Ding, thank you for playing.

    Sean---

    • avatar
    • IanB
    • Thu 28 Jul 2005 09:31 AM

    I still like the javascript idea as neatest.

    I tried out the base tags (multi per page) and it does work, even if it isn't valid.

    • avatar
    • Jake Howlett
    • Thu 28 Jul 2005 11:36 AM

    Interesting that you can have multiple <base target> tag and toggle the target for links that way. Seems perverse but if it works...

    However, I'm probably going to stick to my guns and make sure all links I create have target=self in them.

  4. I can hear my dad saying "that's the way it's going to be because I said so!!!"

    Sean---

  5. I used the multiple base tag trick in my very first commercially shipping Domino web template despite the fact that I knew it was invalid HTML. It worked, but whenever I thought about it I felt like I needed to take a shower to wash off the slime.

    -rich

  6. Tony, at least HTML 4.01 and XHTML 1.0 Transitional still contain the base element with target attribute. When writing for these standards, I couldn't care less about what's in the Strict specification.

    And while the JavaScript approach probably works absolutely fine (especially, if the user environment is so well defined as in this case), I still wouldn't call it an ideal solution. In the first place, we should have an easy way in our CMS to seperate internal from external links. And I think, if all external links are entered by users using our own little app only, it could be done even with Domino. If Jake was paid enough for that ... ;-)

  7. ...and if the target attribute is invalid in a particular doctype, it doesn't matter whether you set it declaratively (in the document source) or programmatically, except that there wouldn't be a validation error on load. Instead, the UA should either return an "invalid attiribute" error when the code runs or ignore the nonsense attribute once it is set. (Which of those should happen depends on whether you believe users should report concrete errors or "weird behaviour" when they file their trouble tickets.)

  8. Well, as far as separating out internal and external links, the current script I have actually checks to see if the hostname is the same as my site. If you look at the source on my site, you will see the most up-to-date script. I am sure that if I took a couple of minutes, I could remove the hard coded host name and make the function be completely independent.

    Sean---

Your Comments

Name:
E-mail:
(optional)
Website:
(optional)
Comment:


About This Page

Written by Jake Howlett on Wed 27 Jul 2005

Share This Page

# ( ) '

Comments

The most recent comments added:

Skip to the comments or add your own.

You can subscribe to an individual RSS feed of comments on this entry.

Let's Get Social


About This Website

CodeStore is all about web development. Concentrating on Lotus Domino, ASP.NET, Flex, SharePoint and all things internet.

Your host is Jake Howlett who runs his own web development company called Rockall Design and is always on the lookout for new and interesting work to do.

You can find me on Twitter and on Linked In.

Read more about this site »

More Content