Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7007589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:37:36+00:00 2026-05-27T21:37:36+00:00

Given the following HTML: <html> <head> <link href=http://example.com/g/8c rel=shortlink /> </head> <body></body> </html> How

  • 0

Given the following HTML:

<html>
  <head>
    <link href="http://example.com/g/8c" rel="shortlink" />
  </head>
  <body></body>
</html>

How would I retrieve the contents of href=”” in the link, rel=shortlink with javascript? I don’t know if such items in the head are accessible in the DOM.

The head-tag may contain more link-tags, for assets such as css. The head-tag may contain more then one link-shortlink (as per HTML5 ‘specs’), in that case, just pick the first.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:37:37+00:00Added an answer on May 27, 2026 at 9:37 pm

    You can use document.head to get the head, and then use getElementsByTagName to get the link tags.

    var links = document.head.getElementsByTagName('link');
    for(var link in links){
        if(links.hasOwnProperty(link)){
            var l = links[link];
            if(l.rel === 'shortlink'){
              console.log(l.href);
            }
        }
    }
    

    NOTE: document.head might not work in all browsers (by that, I mean it might not work in IE). If it’s not working try this:

    document.head = document.head || document.getElementsByTagName('head')[0];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given the following HTML file: <!DOCTYPE html5> <html> <head> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js type=text/javascript></script> <script type=text/javascript>
I am using the following html page: <html> <head> <title>AJAX Example</title> <meta http-equiv=Content-Type content=text/html;
Given the following HTML example... <div id='div1'>div one</div> <div id='div2'>div two</div> ...I found that
Given the following markup <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML Strict//EN><META http-equiv=Content-Type content=text/html; charset=utf-8> <HTML
Given the following HTML: <!DOCTYPE html> <html lang='en'> <head> <meta charset='iso-8859-1' /> <title>Test</title> <style>
I would like to solve the following problem: Given a link on a Web
Given this structure for a websinte <html> <head> <!-- CSS at the beginning--> <link/>
given the following code <!DOCTYPE html> <html> <head> <title>show stats</title> <style> span.main { position:relative;
Consider the following Html file: <!DOCTYPE HTML PUBLIC -//W3C//DTD HTML 4.01//EN http://www.w3.org/TR/html4/strict.dtd> <html> <head>
Given the following HTML: <select name=my_dropdown id=my_dropdown> <option value=1>displayed text 1</option> </select> How do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.