Page 1 of 1

copy & paste a website into a form....

Posted: Mon Apr 05, 2004 4:04 pm
by Derfel Cadarn
Hi all,

I've got a sneeky problem to solve, I hope someone can help...

I've got a form (using just HTML and javascript), containing a couple of textfields. The goal is that a user just fills out the form-fields and hits the 'send'-button. Then the javascript combines the contents of the textfields with some prefab-pieces of HTML and the result is an HTML-code for a website containing the info that the user has filled out.....Are you still with me??

Now, my problem: sometimes a user might want to copy-and-paste a part of an existing website INTO one of the textfields (or: into the form) and see it in the resulting webpage (let's just say: I want to show a part of a webpage as evidence). When I use Internet Explorer and Outlook Express (or Frontpage), I just select the part of the website I want to re-use and paste it into the 'almost-ready-website' and Outlook Express shows it as a whole website (so does Frontpage).

But I want to do this in my webform: the user fills out the form and the user can copy-and-paste a part of an existing website into this form. And when he/she hits the 'SEND'-button, the HTML-code for the webpage AND the pasted webpage is generated!

I have no idea IF and when HOW I can do this! Does anybody have any experience with this? Any ideas?
I've got a feeling I'm turning around in circles here.....

Do I need ActiveX-components here? The result just needs to work in Explorer, so no other browser is concerned...

All help would be appreciated!! And any hint!
BTW: I don't want to make the user wander throught the source-code and select the html-code fromthere..

Thanx,

Derfel.

Posted: Wed Apr 07, 2004 3:49 pm
by Derfel Cadarn
* * * BUMP * * *

No one?

Posted: Wed Apr 07, 2004 4:35 pm
by feyd
If I understand right, you want a wysiwyg editor, that you can paste from an already existing page visually, rather than code based. This is doable. You'd have to write a COM compliant paste handler (that's how outlook and frontpage do it) ... Unfortunately, I don't think Javascript is at all COM compliant (exposed to the browser anyways). You'd require an ActiveX component, yes.

Posted: Wed Apr 07, 2004 4:47 pm
by Derfel Cadarn
Thanx Feyd, for your reply!

I've got a piece of code, with which I can create a webpage in which someone can paste HTML-code. That code is then shown as a web-site (the HTML-result). Nothing I wrote, though :oops:

Code: Select all

<html>
<head>
<meta name="GENERATOR" Content="blabla">

<link 
	id="stylesheet"
	rel="stylesheet" 
	href="../../Libraries/Css/Default.css">

<script 
	src="../../Libraries/UI/uiMenu.js"></script>

<script>

function uiHTMLConverter()
	&#123;
	// init properties ***********************************************************
	this.Target = document.getElementById('objHTMLConverter_Box')
	this.Active = null
	this.Command = 'Paste'
	this.CommandBuffer = this.Target.createTextRange()
	
	// init methodes ************************************************************
	this.Reset = uiHTMLConverter_Reset
	this.Convert = uiHTMLConverter_Convert
	
	// start point **************************************************************
	
	
	&#125;

function uiHTMLConverter_Reset()
	&#123;
	document.getElementById(objHTMLConverter_Box)
	this.Active = null
	&#125;
	
function uiHTMLConverter_Convert()
	&#123;
	
	if (!this.Active)
		&#123;
		this.Target.select()
		this.CommandBuffer.execCommand(this.Command)
		this.Target.click()
		&#125;
	&#125;	
</script>
<script for="window" event="onload">

objHTMLConverter = new uiHTMLConverter()

</script>

</head>
<body style="padding:2px; margin:0; background-color: transparent">
<div style="width:100%; height:100%" id="Container" onclick="objHTMLConverter.Convert()">
<textarea id="objHTMLConverter_Box" style="height:0px; width:0px" NAME="objHTMLConverter_Box" onclick="document.write(this.value)"></textarea>
</div>
</body>
</html>
Do you know where I go from here?

Posted: Wed Apr 07, 2004 4:59 pm
by feyd
have you tried using that code and pasting something from a webpage to it? I have no idea if that'd work or not.. I haven't done this sort of work on a webpage before....

Posted: Thu Apr 08, 2004 12:52 am
by Derfel Cadarn
The above code works as follows: you can copy a piece of HTML-code with Ctrl-C and open the page containing the above code and then just left-click onto it. The result of the HTML-code is then shown.
I use it whenever I receive an e-mail in HTML-make-up: I Copy the entire HTML-mail and then click onto the page. As a result I then seen th e-mail as a 'normal' text, without HTML-make-up.

When you look in the source (after clicking onto the page), you don't get the HTML-source back, but just plain text.

You cannot select a part of a webpage and drag it onto the page and get the source-code, though. I think I would need something like that, but I'm not sure anymore how to approach my problem... :cry:

Posted: Mon Apr 12, 2004 3:27 am
by Derfel Cadarn
Well, just to let you all know that my idea IS possible: I've found a solution! Some others have been struggling with the same and they've come up with two solutions: the first one is called Free Text Box and this one is an HTML editor control for ASP.NET and it's written in C#. So not quite what I was looking for.
But exact the thinmg I was looking for, I found as HTML-Area: a WYSIWYG-HTML-editor completely in HTML and Javascript. Exact what I wanted. :lol: 8) :lol: And completely FREE!

Perhaps someone else can use this too!

Thanx all!