Deleting file using SP Services. Jquery - redirect is not working in IE8

I am using the following portion of code to selecting a link in a table row and pull in the values in order to use a SPServices delete function.

for some reason the if/else clause with direct is not working in IE8.  It works in modern browsers (Firefox and Chrome). In IE8 instead of going to the desired URL it is taking me to the default.aspx page in the root directory.

Please let me know if there is a different order/function I should be using..

function deletewarn(el){

var myId = $(el).closest("td").attr("id");
var $leftCell = $(el).closest("td").prev();
var nameURL = $leftCell.attr("name");
var listNameval = "PharmSLT_Meetings_Materials";
//alert(myId + ''  + nameURL + ' ' + listNameval);

var thismeeting = $("#meeting_title").val();
var answer = confirm('Are you sure you want to delete this file?');
if (answer)
//remove file from library	
deleteFile(myId, nameURL, listNameval);
window.location.href="http://itsusmpw00799:56789/prd/hcctesting/Pages/pharmslt.aspx?meeting=" + thismeeting;
window.location.href="http://itsusmpw00799:56789/prd/hcctesting/Pages/pharmslt.aspx?meeting=" + thismeeting;

function deleteFile( itemID, fileRef, listName ) {

	// This is the command needed to delete the specified file. It uses the ID and the URL of the file name. These values must be passed into this function when calling it.

	var path = "http://itsusmpw00799:56789/prd/hcctesting/PharmSLT_Meetings_Materials/";
	var batchCmd = "<Batch OnError='Continue'><Method ID='1' Cmd='Delete'><Field Name='ID'>" + itemID + "</Field><Field Name='FileRef'>" + fileRef + "</Field></Method></Batch>";
	var thismeeting = $("#meeting_title").val;
	// Use SPServices to delete the file.
		operation: "UpdateListItems",
		async: false,
		listName: listName,
		updates: batchCmd,
		completefunc: function ( xData, Status ) {

			// Check the error codes for the web service call.
			$( xData.responseXML ).SPFilterNode( 'ErrorCode' ).each( function(){
				responseError = $( this ).text();

				// If the error codes indicate that the file was successfully deleted, inform the user.
				if ( responseError === '0x00000000' ) {
					alert( "The file has been successfully deleted." );


				// If the error codes indicate that the file was NOT successfully deleted, inform the user.
				else {
					alert( "There was an error trying to delete the file." );

Open in new window

Adam EhrenworthLead Technology AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rainer JeschorCommented:
which jQuery version are you using?
Which SharePoint version and edition?
Adam EhrenworthLead Technology AnalystAuthor Commented:

SharePoint 2007
Rainer JeschorCommented:
thanks a lot.
Hm, the code looks good from the first view. The jQuery library should also be OK with IE8.

Do you have an IE11 instance available?
You might want to try the IE11 debugger and setting breakpoints before and inside the IF statement - but setting the document into the IE8 mode first - which should at the end force IE11 to behave like IE8.

Question: how to you start the function? Is this a click on an a href? Perhaps this is interpreted by IE8 as navigation hence not starting the delete ...
Perhaps you need to prevent event bubbling for this.
Could you perhaps share the code how you start the call to the delete function?

Thanks and HTH
Adam EhrenworthLead Technology AnalystAuthor Commented:
it is a onclick in an a href with javascript that targets the deletewarn function. This link is added as part of a table when the with jquery when the page loads.   Here is a sample...

<a href="" id="xdelete19" onclick="deletewarn(this);">X</a>

Open in new window

Rainer JeschorCommented:
can you change how the onclick is created?
Could you please try this;

<a href="#" id="xdelete19" onclick="deletewarn(this);return false;">X</a>

Open in new window

Adding a hash to the href and a "return false;" to the onclick.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.