Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to combine JavaScript with CDML???

Featured Replies

Before I did use the CDML tag below this one works.

CDML:

<a href="[FMP-LinkRecID: format=details.htm, layout=WEB]" target="_blank">order</a>

Accept that I want a popupwindow which is 450px x 100px without scrollbars & in the center ect.

Now you can see the JavaScript I use. The problem I have is that when the action is happend the wrong FM record is shown. (It is always the last record in FM)

JavaScript using CDML tags:

<script language='javascript'>

var testWindow=null;

function test(mypage,myname,w,h,pos,infocus){

if(pos=='random'){

LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;

TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}

if(pos=='center'){

LeftPosition=(screen.width)?(screen.width-w)/2:100;

TopPosition=(screen.height)?(screen.height-h)/2:100;}

else if((pos!='center' && pos!='random') || pos==null){LeftPosition=100;TopPosition=100;}settings='width='+ w + ',height='+ h + ',top=' + TopPosition + ',left=' + LeftPosition + ',location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,dependent=no';

testWindow=window.open('',myname,settings);

if(infocus=='front'){testWindow.focus();testWindow.location='[FMP-LinkRecID: format=details.htm, layout=WEB]';}

}

</script>

<a href="javascript:test('[FMP-LinkRecID: format=details.htm, layout=WEB]','test','450','100','center','front');">Click Here</a>

I hope some can help me!

Greetings Jukkie

Try changing this:

testWindow=window.open('',myname,settings);

if(infocus=='front'){testWindow.focus();testWindow.location='[FMP-LinkRecID: format=details.htm, layout=WEB]';}

}

</script>
to this:
testWindow=window.open('',myname,settings);

if(infocus=='front'){testWindow.focus();testWindow.location=mypage;}

}

</script>

Good Luck.

Garry

  • Author

Thanks Garry it works!!!

I don't understand why the location is mypage! Can you our somebody else tell my?

Greetings Jukkie

The function called "test" is receiving the URL as a parameter:

function test(mypage,myname,w,h,pos,infocus){

It is being sent from the <a>:

<a href="javascript:test('[FMP-LinkRecID: format=details.htm, layout=WEB]','test','4

"mypage" is a now a variable containing the URL.

All the best.

Garry

  • Author

Thanks Garry,

It's clear now.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.