Category : external

I have the following folder structure: website.com/index.php website.com/page/asd.php website.com/header.php website.com/js/file.js header.php contains: <script src="js/file.js"></script> index.php contains: include_once ‘header.php’; asd.php contains: include_once $_SERVER[‘DOCUMENT_ROOT’] . ‘/header.php’; So file.js will work on index.php, but file.js doesnt work on asd.php. On asd.php the browser want to get /pages/js/file.js (which doesnt exist) and not /js/file.js How can I handle this ..

Read more

I want to get some javascript code using ajax in my main html file. But the javascript code does not work properly. File 1 <button id="button">Button</button> <div id="content"></div> <script> document.getElementById("button").addEventListener("click", display); function display(e) { e.preventDefault(); var xhr = new XMLHttpRequest(); xhr.open("GET", "sample.html", true); xhr.onload = function () { document.getElementById("content").innerHTML = this.responseText; }; xhr.send(); } </script> ..

Read more

I use leafletjs external and defered <script defer src="leaflet.js"></script> i would to run this inline script, just after leaflet run, hope for your help, thanks <script> var map = L.map("map",{maxBounds:[[-90,-Infinity],[90,Infinity]],worldCopyJump:true,scrollWheelZoom:"center",doubleClickZoom: "center",touchZoom:"center"}); L.tileLayer("https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}",{attribution:"Powered by Esri | Esri, HERE, Garmin, USGS, NGA" }).addTo(map); map.setView(llng, zo); </script> Source: Ask Javascript..

Read more

HTML code <head> ….. <script src="confirmExit().js"></script> </head> <body> …. <ul class="nav-container"> <li>Band Member Lowdown</li> <li>Merchandise</li> <li>Fan Forum</li> <li><button onClick="confirmExit()">EXIT</button></li> </ul> … </body> JavaScript code function confirmExit() { var userexit = window.confirm("Do you want to leave this site"); if (userexit == true) { window.confirm("Bye, Call back again soon"); } else { window.confirm("Whoops, did you hit Exit ..

Read more

i’m making a chrome extension for a specific website. This site is made with react. I need to call some functions / variables that are inside some components. How can i made this from a totally external .js? This is what i tried ReactDOM.render(<Page ref={(ourComponent) => {window.ourComponent = ourComponent}} />, document.getElementById("app")); ReactDOM.render(<Page ref={(ourComponent) => {window.ourComponent ..

Read more