Возможно ли в функции Alert (Java script) всплывающего окна , к нажатию кнопки "Ок" прикрепить ссылку? тобешь что бы по нажатию "ок" был переход на сайт ?
|
Возможно ли в функции Alert (Java script) всплывающего окна , к нажатию кнопки "Ок" прикрепить ссылку? тобешь что бы по нажатию "ок" был переход на сайт ?
Привет, как вариант, можно сделать следующее(кастомно задать property для alert)
1)сохраните следующий скрипт отдельно и назовите допустим customAlert.html
<html>
<head>
<style type="text/css">
body{
background-color: buttonface;
overflow: hidden;
}
body, input{
text-align: center;
font-size: 8pt;
font-family: MS Sans Serif;
}
input{
height: 23px;
width: 75px;
}
#myMessageDiv{
padding: 15px;
}
</style>
<script type="text/javascript" language="javascript">
function Init(){
document.getElementById("myMessageDiv").appendChil d(document.createTextNode(window.dialogArguments)) ;
}
function returnOk(){
window.location = "http://translate.google.com/";
window.close();
}
</script>
</head>
<body onload="Init();">
<div id="myMessageDiv"></div>
<input type="button" value="OK" onclick="returnOk();" />
</body>
</html>
2)для того, чтобы использовать этот кастомный alert, пропишите к какому-либо action следующее(сразу пример, как прикрепить к кнопке)
<!DOCTYPE html>
<html>
<body>
<form>
<input type="button" onclick="showModalDialog('customAlert.html', 'Message', 'dialogWidth: 200px; dialogHeight: 120px; help: no;')" value="Show translate.google.com">
</form>
</body>
</html>
При клике, перейдете по ссылке, указанной в window.location
Социальные закладки