/    Sign up×
Community /Pin to ProfileBookmark

WYSIWYG Hyperlinking

Ok I am working on a WYSIWYG(what you see is what you get) rich text editor. It uses an editable Iframe. So basically it uses:

[CODE]objEditor = document.getElementById(‘message’).contentWindow.document;
objEditor.designMode = ‘on’;[/CODE]

and

[CODE]execCommand();[/CODE]

So what I’m trying to do is get hyperlinks to set correctly.
I want something that does the same thing as:

[CODE]function createURL() {
var szURL = prompt(“Enter a URL:”, “http://”);
if ((szURL != null) && (szURL != “”)) {
objEditor.execCommand(“CreateLink”,false,szURL);
}
}[/CODE]

Except I would like to use a CSS “popup”. Basically I just want the same thing, but have it not look ugly, which means using CSS.

I have made it so the popup with a text box and submit button will show up over top of the iframe, but I’m not sure how to get the selected iframe text to become a hyperlink when I submit the form.

This is what I have for the form:

[CODE]<span id=”hlpop”>
<form action=”Javascript:linkit();”>
Address:<br>
<input type=”text” id=”linkaddress”><br>
<input type=”submit” value=”Create Hyperlink”>
</form>
</span>[/CODE]

This is the action of the form:

[CODE]function linkit(){
var urlness = document.getElementById(“linkaddress”).value;
objEditor.execCommand(‘CreateLink’,’true’,urlness);
}[/CODE]

Any ideas? Thanks.

to post a comment
JavaScript

0Be the first to comment 😎

×

Success!

Help @ineedasn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...