Open content in a div tag

I use this code to open a link inside a specific div tag:

<a href="javascript:void(0);" onclick="loadExternalContentmypage();">My page</a>

with this function:

function loadExternalContentmypage() {
        jQuery('#content').load("mypage.html");
    }

This code wil open mypage.html in my div tag with a ID of Content.
The code works fine in firefox and IE, but dosent work in chrome.
Anyone have a suggestion?
or perhaps some other javacode i should use?

Are you working locally without a server? If you are you will need to setup a local server as jQuery requires a same domain policy to exist which file:/// paths don’t offer.

I uploaded the code to the server and it did work. But actually it worked on my local computer as well, somehow just not for crome.

Hello darkloshean,

Just a small tryout, check if the function loadExternalContentmypage() gets called in chrome or not? This might help to trace till were the code is getting executed properly.

Chrome has a same origin policy which blocks this functionality locally, i.e. when testing on your PC without a server running.
You can circumvent this by starting the browser with the following flags: the --disable-web-security.
Here’s a more in-depth explanation: http://stackoverflow.com/questions/3102819/chrome-disable-same-origin-policy

Ah, thats sound’s like it :slight_smile: thanks.