Quantcast
Channel: Active questions tagged header - Stack Overflow
Viewing all articles
Browse latest Browse all 699

Page Load Runs Twice When HREF Attribute Set to "#" in Link Tag

$
0
0

I'm experiencing something weird, that I need help understanding. When I use a link tag with the "href" attribute set to "#", it causes the Page Load event to run twice.

For example, in the following link tag, I'm using "#" as the value for the "href" attribute. I'm using this in place of using a real "shorcut icon" and only to avoid the javascript warning/error. So, I could simply remove it, but I'd like to understand what is goin on (or how to fix it, without removing it):

<link rel="shortcut icon" href="#">

Sample HTML:

<!doctype html><html lang="en"><head runat="server"><title>My Example</title><!-- The "href=#" in the following link tag triggers the 'Page load' event to run twice. --><link rel="shortcut icon" href="#"></head><body><form id="form1" runat="server"><h1>My Example</h1></form></body></html>

Sample VB.NET Code Behind Page:

Partial Class myexample    Inherits System.Web.UI.Page    Private Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load'This is triggered twice.    End SubEnd Class

This also happens with using it for "stylesheet" link tags as shown below:

<link rel="stylesheet" href="#" />  

Viewing all articles
Browse latest Browse all 699

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>