Search code examples
internet-explorerwindows-phone-7

Hyphens in windows phone IE


Need to have hyphens in IE on windows phone 8(or better on both 7/8). I'm using web browser control to show content and i'm embedding some css to make typography prettier. It seems that mobile version of IE is really cropped! For example p:first-child:first-letter is not working..hyphens:auto is not working too. Are there workarounds to add hyphens to margined text?

PS trying Hyphenator.js now, but there is a problem with it, since can't find the way to include local script into the page in webbrowser control(im using NavigateToString).


Solution

  • You can reference local javascript files, but you need to load them into Isolated Storage first.

    This is how you can load them into local storage.

    var fileResourceStreamInfo = Application.GetResourceStream(new Uri("scripts/Hyphenator.js", UriKind.Relative));
    if (fileResourceStreamInfo != null)
    {
    using (BinaryReader br = new BinaryReader(fileResourceStreamInfo.Stream))
    {
        byte[] data = br.ReadBytes((int)fileResourceStreamInfo.Stream.Length);
    
        string strBaseDir = "scripts";
    
        if(!appStorage.DirectoryExists(strBaseDir))
        {
            //Debug.WriteLine("Creating Directory :: " + strBaseDir);
            appStorage.CreateDirectory(strBaseDir);
        }
    
        // This will truncate/overwrite an existing file, or 
        using (IsolatedStorageFileStream outFile = appStorage.OpenFile(AppRoot + "scripts/Hyphenator.js", FileMode.Create))
        {
            Debug.WriteLine("Writing data for " + AppRoot + "scripts/Hyphenator.js" + " and length = " + data.Length);
            using (var writer = new BinaryWriter(outFile))
            {
                writer.Write(data);
            }
        }
    }
    

    }

    Then you can reference them like so:

    <script type="text/javascript" src="scripts/Hyphenator.js"></script>