Javascript Syntax for Social Media Sharing

Testing

I had my post written and it didn’t post so testing 123.

How do I combine this Modeless Window script:

<script>function modelesswin(url,mwidth,mheight){if(document.all&&window.print)
eval('window.showModelessDialog(url,"","help:0;resizable:1;dialogWidth:'+mwidth+'px;dialogHeight:'+mheight+'px")')
else
eval('window.open(url,"","width='+mwidth+'px,height='+mheight+'px,resizable=1,scrollbars=1")')}</script>

With this Facebook sharing code?

<a id=sharefb href="h  tt p s :// facebook .com/sharer/sharer.php?u=http%3A%2F%2F[[[***YOUR DOMAIN HERE***]]]%2F&t=" title="Share on Facebook" target=_blank onclick="window.open('https :// facebook .com/sharer/sharer.php?u=' + encodeURIComponent(document.URL) + '&t=' + encodeURIComponent(document.URL)); return false;"></a>

Both codes work for what they are intended to do. However, instead of

target=_blank onclick="window.open('

I would like to open the sharing referrer to open in the modeless window.

href="javascript:modelesswin(' URL HERE.html',550,575)">

So basically combining

javascript:modelesswin(' ',550,575)

with

<a id=sharefb href="h  tt p s :// facebook .com/sharer/sharer.php?u=http%3A%2F%2F[[[***YOUR DOMAIN HERE***]]]%2F&t=" title="Share on Facebook" target=_blank onclick="window.open('https :// facebook .com/sharer/sharer.php?u=' + encodeURIComponent(document.URL) + '&t=' + encodeURIComponent(document.URL)); return false;"></a>

I tried a dozen different things but could never get the syntax correct.

The message board wiped out the HTML / Javascript. :neutral_face:

The following thread about displaying code should be of some use to you.

3 Likes

Ah yes. There’s usually some new form of code to learn.

I tinkered with the javascript and got it working.

Dynamic Drive’s “Modeless Window” (been on the web for over a decade), by standard:
href="javascript:modelesswin(' URL HERE.html',550,575)"
so how did I get
href="javascript:modelesswin(' and ',550,575)" into all that?

onclick="javascript:modelesswin
(document.URL)',550,575);

:stuck_out_tongue_winking_eye:

It works. That’s all I know.

No tracking analytics… no third party scripts. Nice for a blog as it recognizes the URL in the browser. It works quite like AddToAny but merely 5 kilobytes apprx if using Sprites. Around 20 kilobytes if using Data-URI. Both methods score well in a plain html test document Using sprites: 100/99% Pagespeed/YSlow. Using Data-URI 100/100% Pagespeed/YSlow

Thanks for pointing out the key to posting code on this forum.

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