[BUGFIX] Folder tree in popup throws JS error

When using the folder tree (file, and folder navigation) popup
(browse_links) a JS error occurs when opening new folders.

This is due to incorrect handling of scope.
This patch fixes the error for both RTE and normal link browser.

Change-Id: I25fa0871405e06d6fc084985b3beba6396b872ad
Resolves: #53826
Releases: 6.0, 6.1, 6.2
Reviewed-on: https://review.typo3.org/26816
Reviewed-by: Markus Klein
Tested-by: Markus Klein