/    Sign up×
Community /Pin to ProfileBookmark

tr.execCommand("CreateLink")

Hello all. I’m trying to develop a WYSYWIG html editor. I’m trying to allow the use to create a hyperlink. Below is my code and it works…sort of. Instead of creating a link it is creating a link that looks like this: http://www.mysite.com/”http://mylink.com

[code]

function doEdit2(edit) {
var tr2 = frames.body.document.selection.createRange()
tr2.execCommand(edit)
tr2.select()
frames.body.focus()
}

function set_y() {
var y = body.document.body.innerHTML;
document.theform.body.value = y;
}

[/code]

I’m calling the function like this: onClick=’doEdit(“CreateLink”)’

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@cwilkeyauthorMar 02.2006 — sorry...calling it like: onClick='doEdit2("CreateLink")'
Copy linkTweet thisAlerts:
@phpnoviceMar 02.2006 — There is a second argument that is available for the [URL=http://msdn.microsoft.com/workshop/author/dhtml/reference/constants/createlink.asp]CreateLink[/URL] command identifier.
Copy linkTweet thisAlerts:
@cwilkeyauthorMar 03.2006 — Those arguments are only valid if you do not want to prompt the user for an address. I think the problem is in the function set_y().

<i>
</i>function set_y() {
var y = body.document.body.innerHTML;
document.theform.body.value = y;
}


If I do an "alert(y), it shows the correct URL.
Copy linkTweet thisAlerts:
@phpnoviceMar 03.2006 — Those arguments are only valid if you do not want to prompt the user for an address.[/QUOTE]
Not so. The first argument (to the CreateLink function) is for that purpose. The second argument (to the CreateLink function) is for the url. Did you even read the link I supplied? :rolleyes:

document.execCommand('CreateLink', , url);
Copy linkTweet thisAlerts:
@cwilkeyauthorMar 03.2006 — Yeah, I did and it nothing for me.
Copy linkTweet thisAlerts:
@phpnoviceMar 03.2006 — Welp, so sorry.
×

Success!

Help @cwilkey 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.28,
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,
)...