Set title and meta-tags dynamic with jQuery??

The Facebook scraper doesn’t execute JavaScript. So using Javascript to set the metatags content won’t work.
You have to set OG meta data into the HTML code delivered when the URL is requested. You can simply say “VIEW PAGE SOURCE” … That’s how it works.

THIS CODE Won’t Work for Social Share
function changeMetaInfo()
jQuery(“head”).append(‘<meta property=”og:title” content=”RadioForge – [RANDOM-TITLE]”>’);

document.title = “RadioForge – [RANDOM-TITLE]”;


Other solution

Say you have a player page (player.php) showing current playing radio title / artist (metadata) on page… here you can’t set meta tags & title using JavaScript for social share on Twitter, Facebook or Google.

>> metadata.php write JSON file json/metadata.json for current playing radio titles

{“title”:”RadioForge – [RANDOM-TITLE]”}

You can make a new page (share.php) where you can set those meta tags & title using JSON file json/metadata.json (written by current playing metadata process on player.php) and redirect it to domain player page.

When you share page URL …. it actually shares share.php with just title / tags

Social Share



$sjson = file_get_contents("json/metadata.json");

$mjson = json_decode($sjson, true);

if(isset($mjson['title']) && $mjson['title']!="")
 $ptitle = $mjson['title'];

?><!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title><?php echo $ptitle; ?></title>
<meta property="og:title" content="<?php echo $ptitle; ?>" />

<script language=javascript>
function redirect(){
  window.location = "";


<body  onload="redirect();">


Posted in: HTML5, JavaScript