michelleisconfused michelleisconfused - 1 year ago 53
PHP Question

window.location not navigating to the correct location after page load is complete

When my website loads the javascript below it navigates to the correct anchor tag, but when the remainder of the page is loaded (other content via javascript + ajax) a split second later the page is pushed down way beyond the anchor tag. Is there anyway to call window.location (the javascript below) after all other php + javascript is loaded?

window.location = (""+window.location).replace(/#[A-Za-z0-9_]*$/,'')+"#<?php echo $windowlocation; ?>"

Answer Source

If you are loading via ajax, then you can presumably use the call back methods and some kind of method to check for when they are all done.

var sectionsLoaded = 0;
var numSections = 1; // number of sections you are loading

    complete: function(){

function doneLoading(){
     if(sectionsLoaded == numSections) {
        //Do something

Hopefully this answers your question, or is at least in someway useful. Also to be clear the PHP isn't loading. It is being executed on the backend and does nothing to the front end. (you might already know this just the way your question was worded was a bit confusing)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download