Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Apr 2003
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    browse for url and return value

    I am currently using IFRAMEs and the execCommand interface for simple WYSIWYG content editing for one of my sites.

    The code only needs to work for IE 5.5/6

    I would like to be able to make it easy for the admins to navigate to a page in their browser and automatically take the url and title of the page and enter them as a link in the content being edited. I know I can use -

    document.write('<a href="' + document.location + '">' + document.title + '</a>');

    to get the url and title to form the link. So what I have at the moment is this -

    While editing their content they click on a button which opens a second small window (with nav buttons and menus) containing a frameset with the javascript code at the bottom for taking the data and sending it back to the parent page.

    Obviously if they enter a url in the address bar and then navigate through to find the page they want, the frameset and code are no longer there. Also if they use a link from there favorites it will get rid of the frameset.

    Any suggestions for how to achieve this would be very much appreciated. Thanx in advance for any ideas.

    Nick

  • #2
    New Coder
    Join Date
    Apr 2003
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Please. Pretty please.

    Somebody must have some ideas as to how to achieve this - or a suggestion for another approach.

  • #3
    Regular Coder
    Join Date
    Feb 2003
    Posts
    638
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You might try something like this, to allow drag-n-drop linking to local files (html, txt, or images):

    Code:
    <html><head><title>Drag-n-Drop File Linking:</title>
    
    <script type="text/javascript">
    
    function DropWindow(){MyDiv.style.visibility="hidden";
    var page="";
    page+="<html><head><title>Drop</title></head><body onbeforeunload='opener.MyForm.reset()'>";
    page+="<div align='center' style='height:100%;background:#000;color:#fff'>";
    page+="Drop it HERE:</div></body></html>";
    brwsr=window.open("NonExistent.html","","width=300,height=150,top=0,left=0");
    brwsr.document.write(page)}
    
    function ReturnURL(){
    var FileLocation=brwsr.document.URL.replace(/^(file:\/\/)/,"file:\/\/\/");
    var FileTitle=brwsr.document.title;
    var FileName=brwsr.document.URL.split("\\");
    if(FileTitle != ""){MySpan.innerHTML="<a href='"+FileLocation+"'>"+FileTitle+"</a>"}
    else MySpan.innerHTML="<a href='"+FileLocation+"'>"+FileName[FileName.length-1]+"</a>";
    brwsr.window.close();MyDiv.style.visibility="visible";}
    </script>
    
    <style "type=text/css">
    .drag{border:3px double #ff0000;padding:10px}
    </style>
    
    </head><body>
    <div id="MyDiv" class="drag" ondragenter="DropWindow()">
    Drag *.html, *.txt, or image files here (<small>& drop into new window</small>):</div>
    <form id="MyForm" "name=invisible" onreset="setTimeout('ReturnURL()',0)"></form>
    <span>A link should appear here: </span><span id="MySpan"></span>
    </body></html>


    onreset="setTimeout('ReturnURL()',0)" may need to be increased, but works for me at "0"...


    EDIT:
    -----------------------------------
    actually, that code doesn't seem to work online... only from a local file... must be a browser-security issue?
    -----------------------------------
    Last edited by swmr; 07-05-2003 at 10:44 PM.

  • #4
    New Coder
    Join Date
    Apr 2003
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanx for your suggestion. It's given me some food for thought.

    Thanx again


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •