问题描述
我想在用户点击图片时使用收件人地址打开一个新的Outlook邮件模板。我已经返回我的代码在HTML页面(与图像链接),每当它加载JavaScript应该打开一个新的邮件模板。但功能不起作用。请让我知道我的代码中有什么问题。
body onLoad =redirect()
script language =JavaScript
函数重定向()
var email [email protected]
var mailto_link ='mailto:'+ email
window = window.open(mailto_link,'emailWindow')
if(window& window.open&&!window.closed)
window.close()
不需要jQuery。而且没有必要打开一个新窗口。协议不会返回HTTP数据到浏览器( mailto:, irc:// , magnet:, ftp:// (< - 取决于它是如何实现的,通常浏览器内置有FTP客户端) )可以在同一窗口中查询,而不会丢失当前内容。在你的情况下:
pre $ function redirect()
{
window.location.href =mailto: [email protected];
}
< body onload =javascript:redirect();>
或者直接
< body onload =javascript:window.location.href ='mailto:[email protected]';>
I want to open a new outlook mail template with the 'To address' whenever a user clicks an image. I have return my code in a html page(linked with the image), whenever it loads the javascript should open a new mail template. But the functionality is not working. Kindly let me know what is wrong in my code.
body onLoad="redirect()" script language="JavaScript" function redirect() var email = "[email protected]" var mailto_link = 'mailto:' + email window = window.open(mailto_link, 'emailWindow') if (window && window.open && !window.closed) window.close()
No need for jQuery. And it isn't necessary to open a new window. Protocols which doesn't return HTTP data to the browser (mailto:, irc://, magnet:, ftp:// (<- it depends how it is implemented, normally the browser has an FTP client built in)) can be queried in the same window without losing the current content. In your case:
function redirect() { window.location.href = "mailto:[email protected]"; } <body onload="javascript: redirect();">
Or just directly
<body onload="javascript: window.location.href='mailto:[email protected]';">
这篇关于mailto使用javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!