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
Add a ment  | 

3 Answers 3

Reset to default 3

You 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