Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

split function in Safari

Posted on 2007-11-18
2
Medium Priority
?
945 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

This article discusses how to create an extensible mechanism for linked drop downs.
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?
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

715 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