Solved

split function in Safari

Posted on 2007-11-18
2
926 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
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.
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…

777 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