Need a Short Code making a java script snippet in a pop up

I am researching and found post very close to what I need:

The post contained a code which displayed a pop up on the wordpress site I am creating. Now, I am trying to make to change what the pop up contain or displays. However, what I need to be shown is a java script snippet instead of a website.

I am making this code below:

<!DOCTYPE html>
<html>
  <head>
    <meta charset=utf-8 />
    <title>ColorBox demo</title>
    <link rel="stylesheet" href="http://www.jacklmoore.com/colorbox/example1/colorbox.css" />
  </head>
  <body>
    <h1>Hello, there!</h1>
    <h2>This is some content</h2>
    <p>The popup will open in five seconds</p>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="http://www.jacklmoore.com/colorbox/jquery.colorbox.js"></script>
    <script>
      function openColorBox(){
        $.colorbox({iframe:true, width:"80%", height:"80%", href: "http://www.sitepoint.com"});
      }
      
      setTimeout(openColorBox, 5000);
    </script>
  </body>
</html>

To display my java script snippet which is:

<script type="text/javascript" src="https://goo.gl/coH7w8"></script>

Is this possible?

In addition, I also need it very neat. Like to set this pop up, load after 5 seconds on any page of the website our site visitor opens up. But when they close it or already opt-in on it, it will no longer show up if they navigate navigating on other pages of the site.

Do you want to run a js function into the pop up window?And what is going to do this function?

If you control the href in the iframe, could you not put the script in the head of that page so it will execute?

@ liontas76
Yes, I want to run the js function into the pop up window. It runs an opt in function from a third party site.

I think I do not have any idea how to control href in the iframe. How is that done?

If the page in the iframe is on your server and you have access to it, simply put the code in the head of the page so it will execute.

If you don’t have access to the page that appears in the iframe, then I can’t help you. My knowledgte doesn’t extend that far.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.