Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

HREF Problem

  • 10-11-2005 04:50PM
    #1
    Registered Users, Registered Users 2 Posts: 81 ✭✭


    Hi all

    I'm loading in a series of links to documents in various locations from an XML file for an internal web-based system.

    An example link from the XML file would be:

    <item link="\\myserver\folder1\folder2\my document.doc" target="_blank">My Document</item>

    This works fine through Internet Exploder 6 - it launches the document in a new window. However, when I try testing it in Opera and Firefox, neither of them load the link - instead they automatically put "http://&quot; in front of it and therefore can't find the file obviously.

    Is there a special tag or something I need to include to let Opera and Firefox operate as I need them to?

    Help greatly appreciated!

    Thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 81 ✭✭DC5_ITR


    ok i got around this problem by doing the following:

    map a drive to the network resource
    create a virtual directory under the main virtual directory pointing to this mapping
    update the link to:

    <item link="http://localhost/main_virtual_directory/resource_virtual_directory/folder 1/folder 2/my document.doc" target="_blank">My Document</item>

    this is working now but i'm not sure if this is the best or most efficient way to do this?

    anyone?


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Isn't there a file:// tag?


  • Registered Users, Registered Users 2 Posts: 6,652 ✭✭✭daymobrew


    bonkey wrote:
    Isn't there a file:// tag?
    And don't forget to use forward slashes.
    You could open the file in Opera/Firefox and see what URL it presents.

    I opened a file and got something like (note the 3 forward slashes after 'file'):
    file:///path/to/a_page.html


  • Registered Users, Registered Users 2 Posts: 81 ✭✭DC5_ITR


    the "file://" prefix is one of the first things I already tried (sorry should have mentioned). it does not work with this. when i use the file prefix and run the web app, the following are the results in each browser:

    1) IE = opens the file fine
    2) Opera = opens a blank new page with nothing in it
    3) Firefox = sits there and pretends as if the link wasn't clicked


    maybe it's because it's linking to an unmapped network resource?

    thanks for any help.


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    Ah.

    have you tried with a .txt file? That will tell you if its a problem of the document type, or if its something else. (I'm assuming you're using MS-Word files here, which is giving rise to the .doc)

    The network address not being mapped shouldn't matter, I think. Don't have F'Fox nor Opera where I am at the moment, so I could be totally wrong there.

    Also...from re-reading...are you getting the browser to open up an XML file natively, and clicking on links there, or using the XML to generate HTML? If the latter (which I assume), then your generated HTML will be more relevant than the XML. Can you post a snippet?


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 81 ✭✭DC5_ITR


    nope - it doesn't work with any file extension including .txt.

    i'm writing this with ASP.NET + VB.NET.

    here are a few snippets:

    Sample Generated HTML:
    <h2>Design and Development</h2>
    <li>
    	<a href="\\ServerName\Design and Development\Application Architecture.doc" target="_blank">Application Architecture</a>
    </li>
    <li>
    	<a href="\\ServerName\Design and Development\Client Applications.doc" target="_blank">Client Applications</a>
    </li>
    


    The above is in a protected variable called "msTrainingHTML". This is then glued to the page with the following code:
    <!--Centre column-->
    <td valign="top" align="left" width="429">
    	<table border="0" cellspacing="0" cellpadding="0" width="427">
    		<tr>
    			<td>
    				<h1>Training Documents:</h1><br>
    				<div id="content" style="OVERFLOW: AUTO;">
    					<ul>
    						<%=msTrainingHTML%>
    					</ul>
    					<div id="backtop">
    						<p><a href="#">back to top</a> <img border="0" src="../../images/b2top.gif"></p>
    					</div>
    				</div>
    				<p>&nbsp;</p>
    			</td>
    		</tr>
    	</table>
    </td>
    

    Ultimately producing a list of links that opens the documents in a new window/page.

    You really would want to try this physically on Opera and Firefox - it's been an eye-opener doing this project and seeing the subtle, but annoying differences on pages rendered in each different browser. :mad:

    Thanks for all assitance again.


  • Registered Users, Registered Users 2 Posts: 68,173 ✭✭✭✭seamus


    Use the file:/// href with the server path, using forward slashes. So for e.g.:

    <a href="file://///ServerName/Design and Development/Application Architecture.doc" target="_blank">Application Architecture</a>

    Yes, that's five forward slashes :D
    Tested on both IE and Firefox and works fine for me.

    [Edit: Tested in opera, not working.]

    [Edit2:
    Opera works with just file://ServerName/ etc. A non-foolproof, but usually good way of doing it would be to check the user-agent header to determine how many forward slashes to use.


  • Registered Users, Registered Users 2 Posts: 81 ✭✭DC5_ITR


    nope - refuses to work. same results using what you said there seamus. :(

    you've obviously tested this in your environment and it works given the scenario's you outlined, but it just simply refuses to work here for me. :mad:

    i already have one piece of code to check the browser, which i loathe having to do as it's unclean but circumstances dictated i had to for a different problem - IE and scrollable DIV's can give their own heartache :(
                'Create content div block opening html (IE acts different to Opera and Firefox)
                If Trim$(UCase$(Request.Browser.Browser)) = "IE" Then
                    msBrowserSpecificContentOpener = "id=" & ControlChars.Quote & "content" & ControlChars.Quote _
                                                    & " style=" & ControlChars.Quote & "WIDTH: 420px; OVERFLOW: AUTO;" _
                                                    & ControlChars.Quote
                Else
                    msBrowserSpecificContentOpener = "id=" & ControlChars.Quote & "content" & ControlChars.Quote _
                                                    & " style=" & ControlChars.Quote & "OVERFLOW: AUTO;" & ControlChars.Quote
                End If
    
    

    there must be other factors preventing this from working other than code syntax and structure - maybe the network security or something is causing firefox and opera to simply not work.

    i'll just stick with the way i got it working (as mentioned above with the drive mapping(s) and virtual directories).

    thanks everyone for your assistance - i'll take another look if i have time before final delivery (as if any developer has time before final delivery lol).


  • Registered Users, Registered Users 2 Posts: 15,443 ✭✭✭✭bonkey


    I'm just wondering if its the spaces in your share name. Do you have spaces in your workaround solution?

    jc


  • Registered Users, Registered Users 2 Posts: 81 ✭✭DC5_ITR


    i tried that too before posting the initial question bonkey. i replaced the spaces with %20's all to no avail. there are spaces in my workaround solution.


  • Advertisement
Advertisement