Kosher Kid Posted April 14, 2006 Share Posted April 14, 2006 I am trying to dynamically set the pointer to the css file based on where the help system is installed since that is something the user will control for this system. I've written the following code and it should work but doesn't. Also, I get different behaviors between the html file and the compiled chm help.The html file yields the result: <link rel="stylesheet" type="text/css" href="C:\Clients\Chicago%20Dryer\Chilinc\Help%20System\Html_MS\helpsys.css ">While the compiled chm file yields the result: <link rel="stylesheet" type="text/css" href="@helpsys.css "> if I parse and if I do not parse: <link rel="stylesheet" type="text/css" href="@MSITStore:C:%5CChiApp%5Chelpsys.chm::/Topic.htmhelpsys.css "> Here's the code--(note: to protect confidentiality, I've changed the specific names)<script type=text/javascript>var strStart, strWhere, strEnd, strAll, strSlash, intLast;//set first part of link elementstrStart='link rel="stylesheet" type="text/css" href="';//set last part of link elementstrEnd=' ">';//set slash stringstrSlash ="\\";//determine location of last backslashintLast=location.pathname.lastIndexOf (strSlash) +1;//parse pathname and append help filenamestrWhere= location.pathname.substring (1, intLast) + "helpsys.css";//build complete link elementstrAll=strStart + strWhere + strEnd;//write link elementdocument.write(strAll)</script>Help!!!!!!!! Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 14, 2006 Share Posted April 14, 2006 I can't figure out what exactly you're trying to do. But use this instead, you forgot a <. <script type=text/javascript>var strStart, strWhere, strEnd, strAll, strSlash, intLast;//set first part of link elementstrStart='<link rel="stylesheet" type="text/css" href="';//set last part of link elementstrEnd=' ">';//set slash stringstrSlash ="\\";//determine location of last backslashintLast=location.pathname.lastIndexOf (strSlash) +1;//parse pathname and append help filenamestrWhere= location.pathname.substring (1, intLast) + "helpsys.css";//build complete link elementstrAll=strStart + strWhere + strEnd;//write link elementdocument.write(strAll)</script> Link to comment Share on other sites More sharing options...
Kosher Kid Posted April 14, 2006 Author Share Posted April 14, 2006 I can't figure out what exactly you're trying to do. But use this instead, you forgot a <.Actually, I didn't forget the leading < in my javascript but I did forget to type it into my code sample in my post. I removed it from my running code so that the string results would print at the top of my html page.What I am trying to do is to check the installed location of the help file and then dynamically write the link element to point to the css file.It's the %5C and %20 that I think are the main problem. I know the %20 are substitutes for the space character and, in the compiled help (.chm file) the %5C appear to be substitutes for the \ character.I don't understand why the code yields one result in the html file and a different result in the .chm file. Plus, Microsoft on their website gives no indication that a location statement will return character substitutions.Any further suggestions or thoughts would be appreciated. Link to comment Share on other sites More sharing options...
Little Goat Posted April 14, 2006 Share Posted April 14, 2006 maybe try just using spaces.LG:ph34r: Link to comment Share on other sites More sharing options...
Webworldx Posted April 14, 2006 Share Posted April 14, 2006 Have you tried using file://C:\.. instead of just C:\. Or making the path relative (/folder/file.css) instead of using Javascript? It seems like a problem with the chm compiling rather than a javascript one. Link to comment Share on other sites More sharing options...
Kosher Kid Posted April 17, 2006 Author Share Posted April 17, 2006 I appreciate the suggestions but perhaps I am not being clear.This is not a web-related problem as the .chm file and the access application it supports will be installed on the user's local hard drive.I have no control over where these files will be installed. That's why I'm using JavaScript to determine their location.However, I am getting two problems...One is that I am getting different path results from the uncompiled html file versus the compiled chm file. I am using location.pathname to determine the path: The uncompiled htm file returns: /c:\clients\... The compiled chm file returns: @MSITStore:C:%5CClients%5C...The second is that the javascript return is showing spaces as %20 in the uncompiled htm file, and it is showing slashes as %5C and spaces as %20 in the compiled chm file.That would mean trying to parse for these characters and replacing them with the appropriate slash or space. But I am concerned whether these will really work since I am getting inconsistent results from location.pathname.Also, as best as I can tell from Microsoft, neither of these returns is what I should be seeing.I hope I've clarified my difficulty. Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 17, 2006 Share Posted April 17, 2006 That would mean trying to parse for these characters and replacing them with the appropriate slash or space. But I am concerned whether these will really work since I am getting inconsistent results from location.pathname.Well, if you are getting inconsistent results, that just may be different types of OS's and browsers speaking. Unless it's only on your computer.Also, I'm pretty sure it's simple using str.replace(/%5/gi,"/");. Try that? Link to comment Share on other sites More sharing options...
Kosher Kid Posted April 18, 2006 Author Share Posted April 18, 2006 After much teeth gnashing, chest pounding and head banging, I've come to the conclusion that what I was trying to do simply will not work within a .chm file. I fixed all of the parsing problems and everything else and it still did not do what I hoped.I know the code is good but it appears that within a compiled help file, certain things just cannot be done.My thanks to Chocolate570 and all others who offered suggestions.I've decided to drop back 15 yards and punt! Link to comment Share on other sites More sharing options...
Chocolate570 Posted April 19, 2006 Share Posted April 19, 2006 Can't you run on the 4th down?You can at least change a stylesheet dynamically. That much I know. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now