Note that there are some explanatory texts on larger screens.

plurals
  1. POSEO Safe Anchor Links With jQuery Dynamic Content
    text
    copied!<p>so... Is this a safe way to use internal links on your site.. By doing this i have the index page generating the usual php content section and handing it to the div element. </p> <p><strong>THE MAIN QUESTION:</strong> Will google still index the pages using this method? Common sense tells me it does.. But just double checking and leaving this here as a base example as well if it is. As in.</p> <h2><strong>EXAMPLE ONLY PEOPLE</strong></h2> <hr> <p>The Server Side</p> <pre><code>if (isset($_REQUEST['page'])) {$pageID=$_REQUEST['page'];} else {$pageID="home";} if (isset($_REQUEST['pageMode']) &amp;&amp; $_REQUEST['pageMode']=="js") { require "content/".$pageID.".php"; exit; } // ELSE - REST OF WEBSITE WILL BE GENERATED USING THE page VARIABLE </code></pre> <p>The Links</p> <pre><code>&lt;a class='btnMenu' href='?page=home'&gt;Home Page&lt;/a&gt; &lt;a class='btnMenu' href='?page=about'&gt;About&lt;/a&gt; &lt;a class='btnMenu' href='?page=Services'&gt;Services&lt;/a&gt; &lt;a class='btnMenu' href='?page=contact'&gt;Contact&lt;/a&gt; </code></pre> <p>The Javascript</p> <pre><code>$(function() { $(".btnMenu").click(function(){return doNav(this);}); }); function doNav(objCaller) { var sPage = $(objCaller).attr("href").substring(6,255); $.get("index.php", { page: sPage, pageMode: 'js'}, function(data) { ("#siteContent").html(data).scrollTop(0); }); return false; } </code></pre> <p>Forgive me if there are any errors, as just copied and pasted from my script then removed a bunch of junk to simplify it as still prototyping/white boarding the project its in. So yes it does look a little nasty at the moment.</p> <p>REASONS WHY: The main reason is bandwidth and speed, This will allow other scripts to run and control the site/application a little better and yes it will need to be locked down with some coding. --</p> <p>FURTHER EXAMPLE-- INSERT PHP AT TOP</p> <pre><code>&lt;?php // PHP CODE HERE ?&gt; &lt;html&gt; &lt;head&gt; &lt;link rel="stylesheet" type="text/css" href="style.css" /&gt; &lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="scripts.js"&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div class='siteBody'&gt; &lt;div class='siteHeader'&gt; &lt;?php foreach ($pageList as $key =&gt; $value) { if ($pageID == $key) {$btnClass="btnMenuSel";} else {$btnClass="btnMenu";} echo "&lt;a class='$btnClass' href='?page=".$key."'&gt;".$pageList[$key]."&lt;/a&gt;"; } ?&gt; &lt;/div&gt;&lt;div id="siteContent" style='margin-top:10px;'&gt; &lt;?php require "content/".$pageID.".php"; ?&gt; &lt;/div&gt;&lt;div class='siteFooter'&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload