help: remove "https" from menu links on a secure page

  • jedaffra
  • Novice
  • Novice
  • User avatar
  • Posts: 15
  • Loc: Canada

Post 3+ Months Ago

Hi,

I have a web form secured using https on a classic .asp page (vbscript).

Example https://domainname.com/content/form.asp

If people decide not to fill out the form, and decide to click on one of the menu links on the page, the links all start with "https", which I don't want.

How can I get around this? I had no luck finding an answer on Google.

Thanks in advance.

J
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Truce
  • Guru
  • Guru
  • Truce
  • Posts: 1477
  • Loc: Washington DC

Post 3+ Months Ago

Instead of using relative links use absolute links. In other words, instead of just typing "/contact.php", type "http://example.com/contact.php".
  • jedaffra
  • Novice
  • Novice
  • User avatar
  • Posts: 15
  • Loc: Canada

Post 3+ Months Ago

That's a quick and dirty way to do it.

I was hoping someone had come across a scripted approach to solve the problem - but this will do.

Cheers, Truce.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

This depends on Javascript, but if your menu has an #ID.

Code: [ Select ]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Title</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>
<body>
    <ul id="menu">
        <li><a href="/stuff.html">Stuff</a></li>
        <li><a href="/more-stuff.html">More Stuff</a></li>
    </ul>
    <form action="test.html" method="get">
        <input type="submit" name="submit" id="submit" value="Submit"/>
        <a href="help.html">Help</a>
    </form>
    <script type="text/javascript">//<![CDATA[
    var links = document.getElementById('menu').getElementsByTagName('a');
    for(var i = 0; i < links.length; i++)
    {
        if(links[i].href)
        {
            links[i].href = links[i].href.replace(/^https:/i, 'http:');
        }
    }
    //]]></script>
</body>
</html>
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4.     <title>Title</title>
  5.     <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  6. </head>
  7. <body>
  8.     <ul id="menu">
  9.         <li><a href="/stuff.html">Stuff</a></li>
  10.         <li><a href="/more-stuff.html">More Stuff</a></li>
  11.     </ul>
  12.     <form action="test.html" method="get">
  13.         <input type="submit" name="submit" id="submit" value="Submit"/>
  14.         <a href="help.html">Help</a>
  15.     </form>
  16.     <script type="text/javascript">//<![CDATA[
  17.     var links = document.getElementById('menu').getElementsByTagName('a');
  18.     for(var i = 0; i < links.length; i++)
  19.     {
  20.         if(links[i].href)
  21.         {
  22.             links[i].href = links[i].href.replace(/^https:/i, 'http:');
  23.         }
  24.     }
  25.     //]]></script>
  26. </body>
  27. </html>
  • jedaffra
  • Novice
  • Novice
  • User avatar
  • Posts: 15
  • Loc: Canada

Post 3+ Months Ago

Hey, Joe!

For this problem, I'm wary of javascript b/c not everyone has it turned on. The site is a government run show, so I'm hesitant to use it. That being said, I'm still going to try it out.

And thanks much for posting it.

BTW, I had a look at your blog - nice job on the Picksel app. I use colorpix from time to time. It's nice to know there's an alternative if I ever switch to Ubuntu.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 143 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.