I want to be able to create a list of links that can be called through JavaScript on multiple sites, something similar to blogrolling.com, but hosted on my own site. It seems like it should be simple enough, but I have no idea how to do it. I've searched the net over and over, and, unless I'm searching the wrong thing... I just can't find anything!
So I've discovered I can do this with document.write I don't know anything about javascript, would this be ok? I've got something like this: document.write("<a href=\'http://example.com\'>Example</a>"); document.write("<br />"); document.write("<a href=\'http://example.com\'>Example</a>"); document.write("<br />"); document.write("<a href=\'http://example.com\'>Example</a>"); It works fine on my side, but will it work cross browser? Is it the right way to do this?
Yeah I think that should be ok. Not sure exactly how you're doing it , but you can call a php script from a javascript tag like <script src="http://mysite.com/script.php"></script> and then have the php fetch the results or whatever and then just send javascript output. The javascript output could be as simple as the lines you posted above.
Well if you call a php script, you can generate the links dynamically that will be output via javascript. If you only use javascript you will pretty much be limited to using a static list of links, which means you'll have to update them manually. Or you could run a php script on the server side that isn't accessible to the public that runs with cron(you schedule how often it runs) to generate your link list and then dump the output to a plain .js file. Then you just call the .js file like normal from your html page. It just depends on exactly what your needs are. You can also call script.js and configure things on your server so it's executed as php, but that's a whole other topic and probably not what you're worried about right now.