View Full Version : browse for url and return value

07-03-2003, 02:58 AM
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.


07-04-2003, 12:37 PM
Please. Pretty please.

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

07-05-2003, 11:23 PM
You might try something like this, to allow drag-n-drop linking to local files (html, txt, or images):

<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>";

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>";

<style "type=text/css">
.drag{border:3px double #ff0000;padding:10px}

<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>

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

actually, that code doesn't seem to work online... only from a local file... must be a browser-security issue?

07-06-2003, 03:29 AM
Thanx for your suggestion. It's given me some food for thought.

Thanx again