Solved

split function in Safari

Posted on 2007-11-18
2
920 Views
Last Modified: 2013-12-07
Can somebody please help me with the following code snippet? It works in all the browsers except for Safari, and it's driving me nuts. Thanks so much.
function addFileListToSelect(listVal) {

  alert(listVal);            // shows "Tabor-2117.qdfm;" (as expected)

  

  var teststring = "ab-bc-cd";

  var testarray = teststring.split("-");

  alert(testarray[0] + "\n" + testarray[1] + "\n" + testarray[2]);

         // shows "ab\nbc\cd" (as expected)
 

  alert(listVal);            // shows "Tabor-2117.qdfm;" (as expected)

  var fileNameArray = listVal.split("-");

  alert(listVal);            // shows "Tabor-2117.qdfm;" (as expected)

  if(fileNameArray == null) alert("null");

                             // shows "null" (huh???!!!)        

}

Open in new window

0
Comment
Question by:tjgquicken
2 Comments
 
LVL 29

Accepted Solution

by:
Göran Andersson earned 500 total points
ID: 20308405
What are you sending into the function? If it's not a string, you might get unexpected results.

If you make sure that it's a string that you are using the split method on, does it change things?

var fileNameArray = String(listVal).split("-");
0
 

Author Closing Comment

by:tjgquicken
ID: 31409817
That was it. Thank you very much.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently found myself in a Corporate Situation where the client had requested blocking access to any and all websites except his own Domain? Easy? I am sure this would be your answer but their requirement was, this has to be done without using…
Several part series to implement Internet Explorer 11 Enterprise Mode
Google currently has a new report that is in beta and coming soon to Webmaster Tool accounts. This Micro Tutorial will highlight new features for Google Webmaster Tools.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now