如何从文本框传递文本以在警报框中显示为超链接 [英] How do I pass a text from textbox to appear as a hyperlink in alertbox

查看:83
本文介绍了如何从文本框传递文本以在警报框中显示为超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户将在文本框中输入H :: Click Here = http://ddgd.com :: H此文本。

在按钮单击事件中,此文本必须显示在警告框中,如单击此处作为超链接,它应与链接绑定为值。单击超链接时,它应该重定向到给定的链接。



谢谢。



我尝试过:







< title>

标题
























function viewMe(){

var message = document.getElementById('mytext')。value;

var pos = message.search('=');

var name = message.substring(3,pos);

var url = message.substring(pos + 1,message.length - 3);

alert(name.link(url));

User will enter H::Click Here=http://ddgd.com::H this text in textbox.
On button click event, this text has to appear in alert box as Click Here as hyperlink and it should be binded with the link as value. On clicking the hyperlink, it should redirect to the given link.

Thanks.

What I have tried:



<title>
Title












function viewMe() {
var message = document.getElementById('mytext').value;
var pos = message.search('=');
var name = message.substring(3, pos);
var url = message.substring(pos+1, message.length - 3);
alert(name.link(url));

推荐答案

您不想为此使用alert()。它的文字总是纯文字。



You do not want to use an alert() for this. It's text is always plain text.

    你必须选择basoc:

  1. 创建你自己的盒子(一个< ; div>)可以包含一个链接(隐藏/可见)。
  2. 使用confirm()框并根据返回,转到链接位置或不要。
    You have to basoc options:
  1. Create your own box (a <div>) which can contain a link (hidden/visible).
  2. Use a confirm() box and base upon the return, go to the link location or don't.



免费附加提示:使用如果使用confirm()路由,location.assign()将转到特定的链接位置。


Free additional hint: use location.assign() to go to a specific link location if you use the confirm() route.


这篇关于如何从文本框传递文本以在警报框中显示为超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆