Open a new window and get its location after loading


I am using this code to open a new window:

Window w ='', 'example2'); // Consisder than my domain
                                                    // is

This part of code works ok and succesfully opens a new window. Than i am trying to call my function after loading finishes.


This is a code of locationGetter() function:

locationGetter(Event e) {
  Location currentLocation = w.location;
  currentHref = currentLocation.href; // currentHref is var defined
}                                    // in main() function

But this code doesn’t work well. Every time when I run my script both currentLocation and currentHref is null. At the beginning i thought that problem was in onLoad event, so i tried to call w.location exacly after opening a window:

Window w ='', 'example2');
Location currentLocation = w.location; // still null

I am pretty sure that both Window and WindowBase has location property. Please help me with my problem or provide alternative solution of this task.


I don’t think this is a Dart issue.

Seems you run into this

CORS prevents accessing windows of other domains, you can use postMessage instead.

Answered By – Günter Zöchbauer

Answer Checked By – Cary Denson (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *