Bug Tracker

Modify

Ticket #10593 (closed bug: invalid)

Opened 19 months ago

Last modified 19 months ago

The "href" attribute of <a> element lost when using append() in old IE

Reported by: abiao.chen Owned by: abiao.chen
Priority: low Milestone: None
Component: manipulation Version: 1.7b2
Keywords: Cc:
Blocking: Blocked by:

Description

After calling append() to add a element by passing a string arg which declares an <a> element with both "href" and "onclick" attributes, I found in some IE versions (such as IE <9 on windows server 2003) the "href" attribute was lost.

I traced the execution and found in cloneAttributes() function:

  1. Each of src&dest had the "href" attribute at the beganning.
  2. All the attributes of dest was cleaned by cleanAttribute().
  3. The "href" attribute was missed when merge the src attribute into dest by calling mergeAttributes().

Does this a jQuery or IE problem?

Here is the HTML file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<script type="text/javascript" src="jquery-1.5.min.js"></script>
		<script>
			function addcontent() {
				$("div").append('<a href="javascript:b;" onclick="alert(0)">link3</a>');
			}

			$(document).ready(addcontent);
		</script>
</head>
<body>
	<a href="javascript:x;" onclick="alert(0)">link1</a>
	<div></div>
</body>

Change History

comment:1 Changed 19 months ago by timmywil

  • Owner set to abiao.chen
  • Priority changed from undecided to low
  • Status changed from new to pending
  • Component changed from unfiled to manipulation

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket.

Additionally, be sure to test against the jQuery Edge version to ensure the issue still exists. To get you started, use this boilerplate:  http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to get started.

comment:2 Changed 19 months ago by abiao.chen

  • Status changed from pending to new

I found this bug in IE6 and tried jsFiddle. While in IE6, jsFiddle doesn't work and cannot test this bug. Thus, I paste my code here.

comment:3 Changed 19 months ago by timmywil

  • Status changed from new to closed
  • Resolution set to invalid

The javascript pseudo protocol has many issues in IE6. I recommend steering clear of using it.

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.