Jquery 在新窗口中打开链接,html表上的javascript
我的表中的链接有问题 我使用:Jquery 在新窗口中打开链接,html表上的javascript,jquery,html,Jquery,Html,我的表中的链接有问题 我使用: <script type="text/javascript"> jQuery(document).ready(function($) { $(".clickable-row").click(function() { window.document.location = $(this).data("href"); }); }); </script> 在: 不起作用
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".clickable-row").click(function() {
window.document.location = $(this).data("href");
});
});
</script>
在:
不起作用
有什么想法吗?窗口。打开('href')
窗口位置设置当前窗口的位置。窗口。打开('href')
窗口位置设置当前窗口的位置。使用
Window.open=”怎么样http://....“,”target=“\u blank”)
使用
窗口如何。打开=”http://....“,”target=“\u blank”)
你可以像这样做:
jQuery(document).ready(function($) {
$(".clickable-row").click(function() {
if(this.hasAttribute("target")){
window.open($(this).data("href"),$(this).data("target"));
}
else{
window.document.location = $(this).data("href");
}
});
});
检查
编辑:
以下是您评论的解决方案:
jQuery(document).ready(function($) {
$(".clickable-row").click(function() {
if(this.getAttribute("href").substr(this.getAttribute("href").length - 3)=== "###"){
window.open(this.getAttribute("href").substring(0, this.getAttribute("href").length-3),"_blank");
}
else{
window.document.location = $(this).data("href");
}
});
});
你可以这样做:
jQuery(document).ready(function($) {
$(".clickable-row").click(function() {
if(this.hasAttribute("target")){
window.open($(this).data("href"),$(this).data("target"));
}
else{
window.document.location = $(this).data("href");
}
});
});
检查
编辑:
以下是您评论的解决方案:
jQuery(document).ready(function($) {
$(".clickable-row").click(function() {
if(this.getAttribute("href").substr(this.getAttribute("href").length - 3)=== "###"){
window.open(this.getAttribute("href").substring(0, this.getAttribute("href").length-3),"_blank");
}
else{
window.document.location = $(this).data("href");
}
});
});
我通过添加两个类和两个函数修复了该问题:
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".istiprozor").click(function() {
window.document.location = $(this).data("href");
});
$(".noviprozor").click(function() {
window.open($(this).data("href"),$(this).data("target"));
});
});
</script>
jQuery(文档).ready(函数($){
$(“.istiprozor”)。单击(函数(){
window.document.location=$(this.data(“href”);
});
$(“.noviprozor”)。单击(函数(){
window.open($(this.data(“href”),$(this.data(“target”));
});
});
我通过添加两个类和两个函数解决了这个问题:
<script type="text/javascript">
jQuery(document).ready(function($) {
$(".istiprozor").click(function() {
window.document.location = $(this).data("href");
});
$(".noviprozor").click(function() {
window.open($(this).data("href"),$(this).data("target"));
});
});
</script>
jQuery(文档).ready(函数($){
$(“.istiprozor”)。单击(函数(){
window.document.location=$(this.data(“href”);
});
$(“.noviprozor”)。单击(函数(){
window.open($(this.data(“href”),$(this.data(“target”));
});
});
在谷歌搜索opennewwindowjavascript
或类似术语有多难?这里提出的问题应该表明至少已经尝试了一些研究工作。您的代码应该是window.open($(this.data)(“href”)我当然知道。我只需要在新窗口中打开一些链接,而不是全部。我不会发布用谷歌很容易解决的问题……在谷歌搜索opennewwindowjavascript
或类似的术语有多难?这里提出的问题应该表明至少已经尝试了一些研究工作。您的代码应该是window.open($(this.data)(“href”)我当然知道。我只需要在新窗口中打开一些链接,而不是全部。我不会发布很容易用谷歌解决的Q…但这会在新窗口中打开所有链接。我只需要它来接受target=“\u blank”。我只需要在新窗口中打开一些链接。不是所有的。@JackBauer我会用Jacob的答案,但这会打开新窗口中的所有链接。我只需要它来接受target=“\u blank”。我只需要在新窗口中打开一些链接。杰克鲍尔:我会用雅各布的答案,嗯,这是可行的,但是,我还有一个问题。可视化作曲家“吃掉”目标。请重写此内容,以便如果a href链接的地址中包含######in,它将在新选项卡中打开?示例:www.google.com/####=新建选项卡和www.google.com=相同选项卡。或者我可以分配其他类。效果非常好。谢谢!没问题,很高兴我能帮上忙:Dhmm,它有效,但是,我还有一个问题。可视化作曲家“吃掉”目标。请重写此内容,以便如果a href链接的地址中包含######in,它将在新选项卡中打开?示例:www.google.com/####=新建选项卡和www.google.com=相同选项卡。或者我可以分配其他类。效果非常好。谢谢!没问题,很高兴我能帮忙