scottorchard 8:24pm, 29 August 2005
When the mainpage of the site loads, I get this error:

Error: [Exception... "'Permission denied to call method' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "" data: no]

When I type in the search box, I get this error:

Error: uncaught exception: Permission denied to call method

Livesearch works fine from any other page or post except the mainpage. Also, Livesearch seems to work when I'm logged into the Site Admin. This happens in both FF on a PC or Mac and Safari, IE gives me more errors. I installed the theme and that's it.

Any ideas?
Michael Heilemann [deleted] 11 years ago
I have NO ideas... Anyone? Bueller? Anyone?
Myles Braithwaite PRO 11 years ago
do you have anything that compresses css? are you using php thought cgi? is your index.php file wired?
scottorchard 11 years ago
It looks like this may be a problem with Live Archives and Livesearch. Someone started a thread in the Wordpress Support Forums:

$10 for Live Search and Live Archives

myles3 I haven't compressed css, no php through cgi. What did you mean about a wired index file?
scottorchard 11 years ago
I followed the instructions from the post here on the discussion.

This removed one of the bugs I got in IE.

Then I started to think about the site URL that is referenced in the livesearch.js.php file. It turns out that the address I entered in the Wordpress admin was this, when it needed to be this

I'm not sure if this is related to some security setting for files using XMLHttpRequest on a server, but it solved the problem.

No JS errors in IE, FF on a PC or Mac and Safari works fine as well.

I feel kind of stupid for having this problem, but I hope this helps anyone else that may have had the same problem.
Myles Braithwaite PRO 11 years ago
did you edit the index.php file?

LiveSearch bundled in k2 isn't allowed to open a connection under some conditions.


WP 1.5.2; K2b1r60


JS is not allowed to open cross-domain connections. Your browser sees as a different domain from In livesearch.js.php, line 107, the connection is opened thus:"GET", "<?php bloginfo('template_url'); ?>/livesearch.php?s=" + document.forms.searchform.s.value);

The result of bloginfo('template_url') depends on the 'WordPress Address (URI)' option in wp-admin/ Options -> General.

Steps to reproduce:

If you have www in the WordPress Address option, load your site without it, or vice versa, and watch your browser live up to expectations, making LiveSearch fail.

Possible Fixes: force a www or no www upon page load by using .htaccess or this plugin:

My Fix:

Check the current address in php, adjust the call accordingly. Replace the line in question with:"GET", "<?php fix_request_domain(get_bloginfo('template_url')); ?>/livesearch.php?s=" + document.forms.searchform.s.value);

Add this function somewhere (I did it at the top of livesearch.js.php). Note that it is important to maintain double quotes where they are used but the single ones may be converted.

function fix_request_domain($tentative_url) {

$current_domain = $_SERVER['HTTP_HOST'];
$current_hostname = substr($current_domain, 0, strpos($current_domain, '.'));

preg_match('|http://([^\.]*)\.|', $tentative_url, $matches);
$tentative_hostname = $matches[1];

/* If only one or the other is 'www', adjust it to what the $current is */
if($current_hostname == 'www' xor $tentative_hostname == 'www') {
if($current_hostname == 'www') {
$request_firstpart = "http://www.$tentative_hostname.";
} else {
$request_firstpart = "http://";
$request_url = preg_replace('|http://[^\.]*\.|', $request_firstpart, $tentative_url);
} else {
/* Else just send it back; it's either ok (matching) or it's hopeless (the subdomain differences aren't just a 'www' issue). */
$request_url = $tentative_url;

echo $request_url;

Possible way to make it more elegant: try to open the connection with the normal call, have the js check whether it failed, and if so, try sending it through the above php function.

Another possible way: do the url fixing in js. Probably a waste of time.

Update: had to fix this for super archives too :/ I suggest that k2 recommend forcing a www or non-www hostname whether the user typed in their address bar; redirect the one that isn't what you use in WordPress URI to the one that is.
scottorchard 11 years ago

Thanks for the additional explaination, I hadn't realized that my solution was rather simple and the error would still be there if someone accessed instead of the URL with www in front.

I implemented your fix and everything is working fine.
Groups Beta