Javascript behaving differently in Chrome & Firefox in DetailView

I have some Javascript code that pops up a please wait message

Using Firefox it works in DetailView and EditView but if I use Chrome it only works in EditView

To test it I put the following in a module view.detail.php

public function display() {
		print <<<EOF
function Dialog() {
	\$dialog = \$('<span>Please Wait Processing</span>').dialog({
				open : function() {
					\$(".ui-widget-content").css("background", "yellow");
				modal : true,
				width : 'auto',
				height : '70',
				position : {
					my : 'top',
					at : 'top+150'
		if (empty ( $this->bean->id )) {
			sugar_die ( $GLOBALS ['app_strings'] ['ERROR_NO_RECORD'] );
		$this->dv->process ();
		echo $this->dv->display ();
		print <<<EOF

To make it weirder if I edit a record then save it the message pops up but if I go to the record from ListView it doesn’t

It’s a longshot but if anyone has any idea why this is happening it would make me very happy

I tried using YAHOO.widget.Panel but got the same behaviour