/    Sign up×
Community /Pin to ProfileBookmark

Explanation of what is happening

The below I do not fully understand what is happening

if (document.location.search.match(/type=embed/gi)) {
window.parent.postMessage(“resize”, “*”);
}

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@NachfolgerJun 03.2020 — If the URL contains a parameter "type" which equals "embed", call postMessage.

https://www.w3schools.com/jsref/prop_loc_search.asp

https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage

You can read more on your own.
Copy linkTweet thisAlerts:
@Mandriva99authorJun 03.2020 — Thanks, appreciate the reply. I did read those, I think what i'm not understanding is what is actually meant by "type" & "embed"
Copy linkTweet thisAlerts:
@KeverJun 03.2020 — The part /type=embed/gi is a regular expression. It's doing a global case-insensitive search for the string "type=embed".

For modern browsers you could write document.location.includes("type=embed");
×

Success!

Help @Mandriva99 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...