Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

[Added] JS nuSetIframeProperty(), nuGetIframeProperty()

Information about updates, news, Code Library
admin
Site Admin
Posts: 2806
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

[Added] JS nuSetIframeProperty(), nuGetIframeProperty()

Unread post by admin »

nuBuilder 4.7 introduces two new helper functions—nuSetIframeProperty() and nuGetIframeProperty()—that let you effortlessly set or retrieve a hash cookie inside an iframe.

nuSetIframeProperty()

Syntax:

Code: Select all

nuSetIframeProperty(frameId, property, value, refresh = true)
Parameters:
  • frameId: ID of the <iframe> element
  • property: Name of the property to set via nuSetProperty
  • value: Value to assign to that property
  • refresh: (optional) Whether to call nuGetBreadcrumb() afterwards (default: true)
Return:

Code: Select all

true – if win.nuSetProperty was called (and breadcrumb refreshed if requested)
false – otherwise
What it does:

Sets a Hash Cookie inside the target iframe (of a Run Type object, Method iframe) by invoking its nuSetProperty method (if present), then optionally refreshes it.

Quick example:

Code: Select all

nuSetIframeProperty('customer_iframe', 'date_filter', '2025-12-31');
Before v4.7, you’d have to do something like this:

Code: Select all

var iframe = $("#customer_iframe")[0].contentWindow;
iframe.nuSetProperty("date_filter", '2025-12-31');
iframe.nuGetBreadcrumb();

nuGetIframeProperty()

Syntax:

Code: Select all

nuGetIframeProperty(frameId, property)
Parameters:
  • frameId: ID of the <iframe> element
  • property: Name of the property to retrieve via nuGetProperty
Return:

Code: Select all

Value returned by win.nuGetProperty(property), or null if the iframe or method isn’t found
What it does:
Fetches a Hash Cookie from inside the target iframe by calling its nuGetProperty method.

Quick example:

Code: Select all

let dateFilter = nuGetIframeProperty('customer_iframe', 'date_filter');
console.log(dateFilter); // e.g. "2025-12-31"
Before v4.7, you’d have to do something like this:

Code: Select all

var iframe = document.getElementById('customer_iframe').contentWindow;
var dateFilter = iframe.nuGetProperty('date_filter');
console.log(dateFilter); // e.g. "2025-12-31"
Post Reply