Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

split function in Safari

Posted on 2007-11-18
2
Medium Priority
?
951 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
Suggested Courses

971 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