Bug Tracker

Modify

Ticket #7492 (closed bug: worksforme)

Opened 3 years ago

Last modified 3 years ago

$(element).html() output inconsistent in version 1.4.3

Reported by: ruudrp@… Owned by:
Priority: undecided Milestone: 1.5
Component: unfiled Version: 1.4.3
Keywords: Cc:
Blocking: Blocked by:

Description

It looks like that $(element).html()in version 1.4.3 returns inconsistent output. Using it with latest versions of FF, Opera, Chrome or Safari the output is identical. But in IE8 it is not. This is the code piece that I use.

get the href if any var itemHref = $(this).attr("href"); if (itemHref != "#") {

add the link to the end of the text var divText = itemDiv+" p:last"; var itemDivText = $(divText).html(); var itemHrefTarget = $(this).attr("target"); if (itemHrefTarget!="") {

itemHrefTarget=" target=" + '"' + itemHrefTarget + '"';

} else{

itemHrefTarget=" target=" + '"' + "_blank" + '"';

} var divLink ="<a href=" + '"' + itemHref +'"'+ itemHrefTarget + ">Lees meer.</a>"; only add it if not there yet if(itemDivText!=divLink) {

itemDivText=itemDivText + "<p>" + divLink + "</p>"; $(divText).html(itemDivText);

}

}

Running this in IE8 the value of itemDivText= ="<A href="Visie.html#Ankernaam2" target=_blank>Lees meer.</A>" (Yes caps and no quotes wrapped around _blank.) after adding divLink to the text.

In the other browsers itemDivText=="<a href="Visie.html#Ankernaam2" target="_blank">Lees meer.</a>" What it should be, because that is what the code sets it to when adding divLink to the text.

So I don’t know if it is something I am doing wrong or that it is the quirky behavior of IE8. To me it looks like a Jquery bug. Not cross browser compatible….:-( So hence the ticket.

Obviously in IE8 the link is always added, even if the link is already there. The link itself works fine in IE8 too by the way.

Change History

comment:1 Changed 3 years ago by boushley

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

I think I've parse what you said in your ticket into this jsFiddle  http://jsfiddle.net/boushley/KPyDE/ As far as I can tell things work fine. On IE 8 and Chrome at the console.log itemDivText is set to "<p><a href=" http://www.google.com" target="_blank">Lees meer.</a></p>"

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.