Display a file within a div

Scriber
Scriber used Ask the Experts™
on
I have a page with two divs, one taking up 50% left and the other 50% right. I have links to files on the left and I'd like them to open on the right. I have commented the line of code required //pseudo code.

//page.htm

function openFile(file) {
	document.div("container_right") = file; //pseudo code
}

<div id="container_left" style="color:#FFF; float:left; width:50%;">

function(file) {
	openFile(file);
});

</div>

<div id="container_right" style="color:#FFF; float:right; width:50%";></div>

Open in new window


Thanks in advance!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Slightly different idea here - the code.

Author

Commented:
Hi Proculopsis,

Firstly thank you. That's was what I was after but I'm having trouble implementing it.

I'm using jQuery File Tree and I "need" to insert your code into the "function(file)" call. The "File" variable contains the path and filename.

This example opens the file in a new window.

function openFile(file) {
     window.open(file,'_blank');	
}

Open in new window


Again any help would be greatly appreciated.

Thanks,
Commented:
After a cup of tea and a think I cracked it:

function openFile(file) {
     event.preventDefault(); 
     $("#container_right").prop( { src: file } );
}

Open in new window


Thanks,

Author

Commented:
Thank you. I'd never come across http://jsfiddle.net either so that was a bonus! :)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial