簡體   English   中英

用於將 UTM 發送到 iFrame 的 PHP 代碼的 Javascript 翻譯

[英]Javascript translation for PHP code for sending UTM to iFrame

我使用 PHP 代碼將 UTM 代碼發送到 iframe。 但是如何將其轉換為 javascript 代碼?

<?php 
  $utm_source = $_GET['utm_source']; 
  $utm_medium = $_GET['utm_medium']; 
  $utm_campaign = $_GET['utm_campaign']; 
?> 
<iframe id="typeform-full" width="100%" height="100%" 
 frameborder="0" src="artsenzondergrenzen.typeform.com/to/rdm3VJ?utm_source=<?php echo $utm_source; ?>&utm_medium=<?php echo $utm_medium; ?>&utm_campaign=<?php echo $utm_campaign; ?>"></iframe> 
  <script type="text/javascript" src="embed.typeform.com/embed.js"></script>

感謝你的回復。 我是新手,下次會將代碼放在問題本身中,感謝您幫助我解決這個問題。 我的問題是我有一個完美的 php 代碼,用於將 utm 參數從主機 URL 添加到 iFrame URL。 這是我在 Stack 上多次看到的問題。 所以應該對其他用戶也有幫助。 我的問題是我想在只允許 html 文件而不是 php 的頁面上使用它。 這就是為什么我想翻譯成 javascript 代碼。 但是下面的代碼不起作用,有什么想法嗎?

 <script language="JavaScript"> var nl = getNewLine() function getNewLine() { var agent = navigator.userAgent if (agent.indexOf("Win") >= 0) return "\\r\\n" else if (agent.indexOf("Mac") >= 0) return "\\r" return "\\r" } pagecode = '<?php'+nl+ '$utm_source = $_GET[\\'utm_source\\'];'+nl+ '$utm_medium = $_GET[\\'utm_medium\\'];'+nl+ '$utm_campaign = $_GET[\\'utm_campaign\\'];'+nl+ '?>'+nl+nl+ '<iframe id="typeform-full" width="100%" height="100%" frameborder="0" src="https://artsenzondergrenzen.typeform.com/to/rdm3VJ?utm_source='<?php echo $utm_source; ?>'&utm_medium='<?php echo $utm_medium; ?>'&utm_campaign='<?php echo $utm_campaign; ?>'"></iframe> '+nl+nl+ '<scr'+'ipt type="text/javascript" src="https://embed.typeform.com/embed.js"></scr'+'ipt>' document.write(pagecode); </script>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM