我有这个问题,当我在Firefox中有这个html它打开一个新窗口
<a style="float:right;"
href='javascript:window.location.href="#";'onClick="javascript:addNewRecord();">
New Record</a>
Run Code Online (Sandbox Code Playgroud)
我尝试过self.location,window.location,#body和#h1作为href.
最初我有代码,但在firefox中没有做任何事情,只是打开一个新窗口,而不是执行我的功能.该代码在chrome中非常完美.
<a style="float:right;" href="javascript:addNewRecord();">New Record</a>
Run Code Online (Sandbox Code Playgroud) 我正在查看网站上的一些代码,我看到了以下链接代码:
<a href="#" _mce_href="#">Link Text</a>
Run Code Online (Sandbox Code Playgroud)
什么是_mce_href?
有什么目的吗?
我有以下结构
码
<a href="blah.html" class="re-direct">
<div class="1div"></div>
<div class="2div">
<div class="click" data-id="text">click</div>
</div>
</a>
<script>
$(document).on('click',".click",function(){ alert($(this).data('id')) })
</script>
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,但它重定向到页面blah.html如何阻止它重定向?
如何停止点击事件的传播,以便浏览器不会重定向?
<a id="theHref" href="http://stackoverflow.com/">SO</a>
<script>
document.getElementById("theHref").addEventListener("mousedown", function(event) {
console.log("href clicked, lets try to stop event propagation");
event.stopPropagation();
event.preventDefault();
return false;
});
</script>
Run Code Online (Sandbox Code Playgroud) 我会再试一次,因为我不确定最后一次我提出一个非常明确的问题......我有一个包含很多链接图像的页面。我只想使用 javascript 更改图像链接之一(它是徽标)。我不能直接编辑“body”html,但可以将js放在“head”区域。
这是html代码:
<div id="ctl00">
<h1 class="logo">
<a href="http://www.store.domain.co.nz" title="Menswear"><img src="/user/files/logo.png title="Menswear" alt="Menswear"></a>
</h1>
</div>
Run Code Online (Sandbox Code Playgroud)
我想将 html 更改为:
<div id="ctl00">
<h1 class="logo">
<a href="http://www.domain.co.nz" title="Menswear"><img src="/user/files/logo.png title="Menswear" alt="Menswear"></a>
</h1>
</div>
Run Code Online (Sandbox Code Playgroud)
基本上我想从 URL 中删除“.store”,但只有这个实例,而不是页面上的所有 URL。
我想使用带有href的anchor-tag链接Menu.cshtml页面,这样每当我点击导航栏中的菜单链接时,它应该指向Menu.cshtml.我已经尝试了几次使用此代码,但我无法做到这一点.这是我正在使用的代码:
<a class="page-scroll" href="~/Views/Home/Menu.cshtml">Menus</a>
Run Code Online (Sandbox Code Playgroud) 我必须显示一个<a>标签。但是根据值是否存在,我需要设置href.
这就是我所拥有的:
<a ng-show="source.element!=0" "href="#/resource/{{source.a}}/{{source.b}}/val">
{{source.element}})
</a>
<a ng-show="source.element==0" "href="">{{source.element}}</a>
Run Code Online (Sandbox Code Playgroud)
如果source.element是 0 ,那么点击source.element ( href="")的值时不会发生任何事情
否则,页面必须根据 href 重定向。
有没有更好的方法来做到这一点,因为这会重复代码?
谢谢..
我正在尝试使用动态 URL 将用户带到带有 AngularJS 的外部网站。但是,当点击该链接时,该链接会将用户带到我页面上的路线。
例如,如果我的网址是“mysite.com”,而我的链接是“google.com”。如果我单击此链接,使用href或ng-href,它会将我带到我网站上不存在的路线:“mysite.com/google.com”
如何导航到外部 URL?
我的代码示例:
<a href="{{ linkItem.link }}" target="_blank">View file</a>
Run Code Online (Sandbox Code Playgroud)
而linkItem.link“google.com”。这对于任何网页都无法正常工作,即使对于具有硬编码 href 属性的网页也是如此。
总结:
站点位于https://localhost:3000,Content-Security-Policy值为default-src 'self' 'unsafe-inline' https://localhost:3001/https_index.html包含指向 的 iframe https://localhost:3001/index.html。的内容:3001/index.html包含一个<a href="mailto..."></a>. 单击该链接失败:Refused to frame '' because it violates the following Content Security Policy directive...。如何更改我的 CSP 值以防止出现此错误;在用户首选的电子邮件客户端中打开新电子邮件(正常行为mailto)?我正在使用 Chrome 1
详情:
与此问题类似但不同的是“mailto 链接在框架 chrome 中不起作用(通过 https)”
我认为我的不是重复的,因为:
我无法重现那个错误,当我尝试重现他们的步骤时,我看到一个关于混合内容的控制台警告:
混合内容:位于“ https://localhost:3001/https_index.html ”的页面已通过 HTTPS 加载,但请求了不安全的资源“mailto:...”。此内容也应通过 HTTPS 提供。
我的步骤是具体的;我的页面及其 iframe src 都是https,但页面本身具有特定的限制性 Content-Security-Policy( CSP): …
我有一个来自 Material UI 的图标,我希望它可以点击并打开一个新窗口到 www.linkedin.com
我应该使用 href="Linkedin.com" 吗?或添加 onClick ?我希望它也打开一个新标签/窗口