It's not possible to insert a JavaScript function inside an iframe tag as it may seem like you are trying to do. The purpose behind your attempt is not clearly understood, but here is some guidance:
If the iframe and host document are on different domains, direct JavaScript access between them will be blocked by the browser, except for using window.postMessage()
for communication.
However, if the iframe and host document are on the same domain, you can access the contents of the iframe like this:
// Get the DOM element of the iframe from the host document
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
From there, you can access the window object to interact with global JavaScript variables or functions.
To call a function within an iframe on the same domain, follow these steps:
var iframe = document.getElementById("myIframe");
var iframeDocument = iframe.contentDocument || iframe.contentWindow.document;
var iframeWindow = iframeDocument.window;
// Call the function in the iframe
iframeWindow.funcIniFrame("xxx");
If your goal is to have an iframe with a dynamically generated .src
attribute from the host document, you can achieve that without any domain restrictions by doing the following:
<iframe id="myIFrame"></iframe>
<script>
document.getElementById("myIFrame").src = generateLinkerUrl("http://blog.domain.com/mypage.php");
</script>