Open link inside a div

Asked

Viewed 1,279 times

0

I use a plugin to manage my posts on Wordpress, but I would like to make it open within a DIV specific.

That in which is the #main-view.

Today he finds himself like this : target="_parent"

Below follows the plugin code.

<div class="gw-gopf-post">
	<div class="gw-gopf-post-header">
		<div class="gw-gopf-post-overlay">{{post_overlay_buttons}}</div>
		{{post_media}}
	</div>
	<div class="gw-gopf-post-content-wrap">
		<div class="gw-gopf-post-content">
			<div class="gw-gopf-post-title"><h2><a href="{{post_link}}" target="_parent">{{post_title}}</a></h2></div>
			
		</div>							
	</div>												
</div>

1 answer

0


See if this code with XMLHttpRequest() works on your Wordpress:

Replace the whole <a></a> for this:

<a href='javascript: document.getElementById("main-view").innerHTML="Carregando...";xhr=new XMLHttpRequest();xhr.onreadystatechange=function(){if(xhr.readyState==4&&xhr.status==200){document.getElementById("main-view").innerHTML=xhr.responseText;}};xhr.open("GET","{{post_link}}",true);xhr.setRequestHeader("Content-type","text/html");xhr.send();' target="_parent">{{post_title}}</a>

This code will pull all the HTML from the desired URL into the div #main-view (the URL must be from the same domain).

  • Does it even work if the div is from a domain ? for example ... this wordpress page is an iframe within a main site and when users click their links they can open in the div of the main domain page ?

  • Man, just testing, but I believe so.

  • didn’t work ...disabled text link.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.