1
I made a script in Javascript and PHP, in which I need to get the first keyword (meta keyword) page document.referrer
.
No use using the $_SERVER["HTTP_REFERER"]
which does not work in my case, because the page being executed is inside a iframe, that way, it doesn’t work.
So I made the following code:
// O script abaixo, pega a URL presente do navegador, até aqui funciona perfeito, ele pega certinho o que preciso
<script>
function getParentUrl() {
var isInIframe = (parent !== window),
parentUrl = null;
if (isInIframe) {
parentUrl = document.referrer;
}
return parentUrl;
}
var referencia = getParentUrl();
</script>
<?php
// a variavel abaixo, pega o valor do javascript, e recebe certinho a variavel
$referenciaphp = "<script>document.write(referencia)</script>";
echo $referenciaphp;
//abaixo está o problema
$tags = get_meta_tags($referenciaphp);
echo $tags;
$palavras=$tags['keywords'];
$individual=explode(",", $palavras);
echo $individual[0];
?>
The problem is when to trigger the get_meta_tags
, if I give a echo
in the variable, it shows the right URL, but does not work at the time of picking the tags, I do not know if it is the type of variable that has to change, or something by style.
I tested switching to $referenciaphp = "http://www.uol.com.br/";
, and works perfectly the script.
The problem is only when using a variable coming from Javascript, I don’t know if you have to convert the variable or something like.
Take a look at [tour]. You can accept an answer if it solved your problem. You can vote on every post on the site as well. Did any help you more? You need something to be improved?
– Maniero