WP Pro's - can you make this code work in a post?

by bwh1
9 replies
Hey guy's

this is my last resource before I give up.

Can you please take a look at this and tell me how to resolve it so that one of both codes will work in a WP PAGE (not sidebar widget or post)

This is a Button code

<p>CHECK OUT A LIST OF ALL THE VIDEOS HERE.</p>

<center><button onclick="myFunction()"><strong>Quickbooks University Video List</strong></button></center>

<script>
function myFunction() {
window.open("http://qbuniversity.org/video-overview/", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
}
</script>
-------------------------------------------------------------------------------------------------------------------------------

This is a clickable image code

<a><img name="PopUpWin1" border=0 height=400 width=400 src="http://qbuniversity.org/quickbooks-university-training/quickbooks-2014-tutorials/1-introduction-to-quickbooks/flatecover/" onclick="open_win()"></a>
<script type="text/javascript">
function open_win(){
window.open("http://qbuniversity.org/video-overview/","_blank","toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=500, height=480") }
</script>
I would need that this code works in my homepage, so people click at an image or button and a smaller browser window pop's up on top of my open window.

I tried WP plugins, no success as all have some poblems or work in the sidebar only or popup only once as for list building etc.

Many thanks if I can get some help from someone which knows the fix.

G.

P.S. I thought that WP 3.9 got smarter to accept code like this, but guess I'm wrong.
#make #post #pro #work
  • Profile picture of the author kewkii
    Where are you entering the script? In the page editor?
    How does the page render and what HTML is generated?

    I may be barking up the wrong tree here but would https://wordpress.org/plugins/simple-embed-code/ help? I be never tried it , as I try to have all my JavaScript in a separate Js file rather then embedding it in the main page body
    {{ DiscussionBoard.errors[9321150].message }}
    • Profile picture of the author bwh1
      Originally Posted by kewkii View Post

      Where are you entering the script? In the page editor?
      How does the page render and what HTML is generated?

      I may be barking up the wrong tree here but would https://wordpress.org/plugins/simple-embed-code/ help? I be never tried it , as I try to have all my JavaScript in a separate Js file rather then embedding it in the main page body
      Well, I click at EDIT PAGE and then click at the TEXT tab to enter that code.

      The first one with the button doesn't look any different after I saved it but the button does anything at all when clicked. He appears nicely as it should but there is no link linked to the click (hope that makes sense).

      The second one, the Java code, get simply cut off when saving. I looked for a plugin which let me use Javascript, but there is non to use it inside a page, in the middle somewhere as I need it.

      I never used the plugin you menitoned, will take a look at it if that could help me out.

      Many thanks for your help

      G.
      Signature

      Affiliates Wanted! Make anywhere from 42,- to $72 in commissions. Simply Recommend the Best QuickBooks Pro Video Course available at Clickbank.

      {{ DiscussionBoard.errors[9321723].message }}
  • Profile picture of the author kewkii
    I just tried the code that you posted and it worked OK (I did change URL). Tried it on FireFox and the latest Chrome looking at a local website running WordPress 3.8.. Do you have the URL of the page that isn't working?
    {{ DiscussionBoard.errors[9322410].message }}
    • Profile picture of the author bwh1
      Originally Posted by kewkii View Post

      I just tried the code that you posted and it worked OK (I did change URL). Tried it on FireFox and the latest Chrome looking at a local website running WordPress 3.8.. Do you have the URL of the page that isn't working?
      So you put that code into a page, in the TEXT feauture and it worked? Both?

      I'm running WP 3.9 and the theme is ProfitsTheme, but that shouldn't make any difference.

      G.
      Signature

      Affiliates Wanted! Make anywhere from 42,- to $72 in commissions. Simply Recommend the Best QuickBooks Pro Video Course available at Clickbank.

      {{ DiscussionBoard.errors[9324132].message }}
      • Profile picture of the author kewkii
        Originally Posted by bwh1 View Post

        So you put that code into a page, in the TEXT feauture and it worked? Both?

        G.
        I know! I was surprised it worked too! Post a link to the problem page when you can.
        {{ DiscussionBoard.errors[9325330].message }}
  • Profile picture of the author littleCowCoding
    I have tried the code in isolation and it does work but here are the things I noticed that are wrong with it.

    1) there should be no space between parameters in your window.open function.
    i.e.
    window.open("http://qbuniversity.org/video-overview/", "_blank", "toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

    Should be

    window.open("http://qbuniversity.org/video-overview/","_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");

    Internet Explorer will have problems if there are spaces.

    2)
    Use a suitable function name myFunction helps no one. Also you use two scripts to do the same thing. Rename the popup to something useful like popupVideoOverview()

    Then just reference the function in both links.

    3)
    In the img javascript there is no such parameter as copyHistory.

    4)
    The img you link to is not a valid URL, you need the image full src.

    5)
    The page you link to is full of errors to.

    Regarding it not working in wordpress when you enter the javascript try putting in a XML parser exclude tag. like this..

    <script>// <![CDATA[
    function myFunction() {
    window.open("http://qbuniversity.org/video-overview/","_blank","toolbar=yes, scrollbars=yes, resizable=yes, top=500, left=500, width=400, height=400");
    }
    // ]]></script>

    Let us know if that helps
    {{ DiscussionBoard.errors[9322496].message }}
  • Profile picture of the author bwh1
    Hey, thanks guys

    I took the code off the page (it didn't worked so why leaving it there)

    I'm very happy for your help, will see to squeeze some time to try those tips. Have a bit a stressy week so don't know if I can do it but as soon as I can I will let you know.

    G.
    Signature

    Affiliates Wanted! Make anywhere from 42,- to $72 in commissions. Simply Recommend the Best QuickBooks Pro Video Course available at Clickbank.

    {{ DiscussionBoard.errors[9324127].message }}
  • Profile picture of the author kpmedia
    Just write a custom page template.
    Something like this is really, really easy to do.
    {{ DiscussionBoard.errors[9327625].message }}
  • Profile picture of the author pdhana
    Hi bwh1,

    I suggest not to take off the code as it didn't work. We can sort out the issue. If you need help please do not hesitate PM me. I will try to help you.

    Cheers
    Dhana
    {{ DiscussionBoard.errors[9330242].message }}

Trending Topics