admin管理员组文章数量:1353139
Hey guys is it possible to link a div and url? Basically I want 2 links in one . One link to target the #div and one to target the actual site url in the div.
I am targeting a div but need the url to load in the div.
<a href="" class="class-here">
I can only access the div using this url:
<a href="#modal" class="class-here">
Better way to describe it would be like this, but this does not work obviously:
<a href="" target="#modal" class="second">
I am hiding the div #modal in these tags:
{{#product_page}}
Content is here
{{/product_page}}
Hard one to explain, so any more detail let me know.
Hey guys is it possible to link a div and url? Basically I want 2 links in one . One link to target the #div and one to target the actual site url in the div.
I am targeting a div but need the url to load in the div.
<a href="http://site./product/product-link" class="class-here">
I can only access the div using this url:
<a href="#modal" class="class-here">
Better way to describe it would be like this, but this does not work obviously:
<a href="http://site./product/product-link" target="#modal" class="second">
I am hiding the div #modal in these tags:
{{#product_page}}
Content is here
{{/product_page}}
Hard one to explain, so any more detail let me know.
Share Improve this question asked May 21, 2013 at 12:51 NicoNico 1001 gold badge2 silver badges14 bronze badges 4- Are you asking how to cause the browser to scroll to a div and at the same time to change the HTML of that div to be the same as that of another HTML document? – Quentin Commented May 21, 2013 at 12:53
- no, I want to target the url and div. I want the URL to load in the div #modal if that is an easier explanation... – Nico Commented May 21, 2013 at 12:55
- @pete I thought the same thing, maybe there is a jquery method of doing this? – Nico Commented May 21, 2013 at 12:56
-
yes you can use an onclick on your anchor and do something like:
<a href="#modal" class="class-here" onclick="$('#modal').load('http://site./product/product-link');">
– Pete Commented May 21, 2013 at 12:57
3 Answers
Reset to default 3You were close, it is simply this:
<a href="http://site./product/product-link#modal">
You can link to any id by appending it to the end of the url, as an example, here is a link to my ment
I do not quite understand you want to do but this perhaps work
The id attribute can be used to create a bookmark inside an HTML document.
<div id="tips">Useful Tips Section</div>
Create a link to the "Useful Tips Section" inside the same document:
<a href="#tips">Visit the Useful Tips Section</a>
Or, create a link to the "Useful Tips Section" from another page:
<a href="http://www.w3schools./html_links.htm#tips">
Visit the Useful Tips Section</a>
Source
I found this solution to work:
The HREF link:
<a href="javascript:$.closeit({ direction: 'left', href: 'http://site./product/product-link' })">
Places this script at the bottom of my page:
<script>
$(".class-here").closeit({ direction: "left", modal: true });
</script>
Thank you for everyone who assisted me.
本文标签: javascriptLink a div and URLStack Overflow
版权声明:本文标题:javascript - Link a #div and URL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743925135a2562821.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论