header

Error for Cross Domain AJAX

I was running into an issue at my work. When I clicked a certain link that was supposed to activate an AJAX portion of the site, in Firefox it wouldn’t work and in IE I would get:

This page is accessing information that is not under its control. This is a security risk. Do you want to continue?

The problem was caused by doing an http.open on a domain that was other than that which the script was being run. This wasn’t my intention, so to avoid this issue, I added some server-side host checking, and inserted it into the javascript where necessary:

function getSite(){
var host=<?php echo "'http://".$_SERVER["HTTP_HOST"]."'"; ?>;
if(host != 'http://host1'){
host+='/subdir';
}
return host;
}

I’m sure there’s an easier way, but this worked for me to utilize a “public” and “private” copy of this script without manually editing that value.

Comments (0)

Remove HTML formatting

I was looking for functionality to remove the html tags from text (i.e. anything of this format <*>). I’m sure there’s a built-in PHP function to do this, but I couldn’t find one, so I made a function:

function get_plaintext($in){
//goes from < to the next > and removes it.
return stripslashes(preg_replace('/\< [^>]+\>/','',$in));
}

Comments (2)

WordPress and Custom .htaccess

I’ve found that there is a problematic combination involved with a server-writeable .htaccess file, and a .htaccess file that you have modified. If you put in your own custom edits; for example a download redirection script, then click the Options -> Permalinks section of the weblog control panel, it will overwrite anything you have done to the .htaccess file “automagically” (even without clicking the “Update Permalink Structure” button).

This might be a feature, but has caused me many a headache. So, since I doubt I’ll be changing my permalink structure anytime soon, I made it unwriteable.

Comments (8)

Table-less design

A List Apart has an article about table-less design with CSS which is essential for every web designer.

Edit 7/5/05:
I used this to convert a site I was making for my uncle from a “tabled” design to a “table-less” design. It worked great.

Comments (0)

CSS Reference

w3schools has a great CSS Reference which I find very useful.

Comments (0)


blogtimes