admin管理员组文章数量:1279113
What I want to do is to get the value of value
and open it in new window with a specific size using JavaScript.
HTML
<a id="LNK" href="##" value="edit2.aspx?ren=<%# Eval("GLR_ID") %>" onclick="clickLink()">RENAME</a>
JavaScript
<script type="text/javascript">
function clickLink() {
var myLink = //I need to get the value of `value`
window.open(myLink,'Rename','height=150px','width=250px');
return false;
}
</script>
Please correct my grammar, Thank You.
What I want to do is to get the value of value
and open it in new window with a specific size using JavaScript.
HTML
<a id="LNK" href="##" value="edit2.aspx?ren=<%# Eval("GLR_ID") %>" onclick="clickLink()">RENAME</a>
JavaScript
<script type="text/javascript">
function clickLink() {
var myLink = //I need to get the value of `value`
window.open(myLink,'Rename','height=150px','width=250px');
return false;
}
</script>
Please correct my grammar, Thank You.
Share Improve this question asked Aug 30, 2013 at 3:23 Onel SarmientoOnel Sarmiento 1,6264 gold badges20 silver badges46 bronze badges 1-
The
<%#
tags seem to indicate to me that this involves more than just HTML and Javascript. Off the top of my head, though, I don't actually know what serverside language that is... – Katana314 Commented Aug 30, 2013 at 3:25
5 Answers
Reset to default 2http://jsfiddle/trevordixon/4HE97/
Pass a reference to the anchor to clickLink
:
<a id="LNK" href="##" value="edit2.aspx?ren=<%# Eval("GLR_ID") %>" onclick="clickLink(this)">RENAME</a>
Use getAttribute
to get the value:
function clickLink(a) {
var myLink = a.getAttribute('value');
window.open(myLink,'Rename','height=150px','width=250px');
return false;
}
document.getElementById("LNK").getAttribute("value");
You can get DOM value using getElementByID().value
document.getElementByID('LNK').value
OR
You can pass argument into your onClick
function.
onclick="clickLink(this.value)"
and in function
.
function clickLink(value) {
var myLink = value;
Check out this solution:
function clickLink(e) {
var myLink = e.getAttribute("value");
window.open(myLink,'Rename','height=150px','width=250px');
return false;
}
HTML:<a id="LNK" href="##" value="edit2" onclick="clickLink(this)">RENAME</a>
A working example can be found here
Try this
window.clickLink = function(a) {
var myLink = a.getAttribute('value');
window.open(myLink,'Rename','height=150px','width=250px');
return false;
}
本文标签: htmlGet a href value using JavaScript and open it new windowStack Overflow
版权声明:本文标题:html - Get a href value using JavaScript and open it new window - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741225737a2361823.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论