browser

And this happens with Drupal too!

When creating a node that has for instance a field where you place the embedded code of a youtube video, once submitted the add form, on Chrome the video does not get displayed unless you refresh the page. Basically this is how Chrome prevents XSS attacks.

What i did to solve this momentarily ( workaround) is adding a Javascript refresh page condition on my template.php:


function my_theme_preprocess_html(&$variables) {
	// on chrome we need to reaload the page so the uploaded video can be shown
	// this is due how Chrome prevents XSS (cross-site scripting)
	$u_agent = $_SERVER['HTTP_USER_AGENT']; 
	if(preg_match('/Chrome/i',$u_agent)){ 
	  $bname = 'Google Chrome'; 
	 $ub = "Chrome";	
  }
  if($ub == 'Chrome')
  	$variables['attributes_array']['onLoad'] = "if (location.href.indexOf('reload')==-1) location.replaceā€¦
Read more...
Tuesday, January 24, 2012