Click here to Skip to main content
15,890,947 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Myy problem is that i have an application the app can b read RSS feeds and display them on my page or screen. Also i have used the timer to reload the component of rss feed. I have set some matching keywords like if some keywords match with rss feed result then it will open in a new tab. This works fine when the browser is active but when i am working on any other task or open another window and my browser goes to an inactive state . So now i want to fix this issue how i can fix this ? When the browser is in active the app is not opens the new tabs.

My Code Is :
C#
foreach (var item in Model.Items.OrderByDescending(a => a.PublishDate))
    {
       
                lebel = "New";
                bool ismatch = CommonFunctions.KeyWordsMatches(item, KeyWordsArray, LebelsArray, _settings.Value);
                if (ismatch)
                {
                    syndicationItemList.Add(item);
                     
                    window.open("@item.Links.FirstOrDefault().Uri", '_blank');
                
                }
            
            @rowCount -  @item.Title.Text.ToString()  "color: rgba(255, 0, 0, 1)">  @timeAgo
        
        <div id="demo_@rowCount" class="collapse">
            <p>Link: <a href="@item.Links.FirstOrDefault().Uri.AbsoluteUri" target="_blank">@item.Links.FirstOrDefault().Uri.AbsoluteUri</a></p>
            <p>Publish Date: @item.PublishDate.ToString()</p>
            <p>Description: @Html.Raw(item.Summary.Text)</p>
            
        </div>
    }


What I have tried:

I have checked permissions and Browser setting but it is all fine, but still not working
Posted
Updated 22-Apr-24 3:24am
v2

I believe this is a modern security feature of browsers. Most browsers will not allow windows to be opened without direct input from the user. For example, browsers may require a "click" event, or form "submit" even, or even keyboard press.

The reason for this is simple: websites shouldn't just be able to open whatever windows they like when the page loads. Back in the day it used to be a gamble going onto a website as to whether they'd spawn a bunch more windows redirecting to advertising or even malicious websites.

In your case this would be especially true, a window that's not active and sitting in the background definitely should not be able to spawn new windows or tabs.
 
Share this answer
 
Comments
Aman Zoraiz 23-Apr-24 2:10am    
Thank You for Responding it was helpful
There is no fix for this because it's a security feature. From the MDN Web Docs page on window.open:
Quote:
Modern browsers have strict popup blocker policies. Popup windows must be opened in direct response to user input, and a separate user gesture event is required for each Window.open() call. This prevents sites from spamming users with lots of windows. However, this poses an issue for multi-window applications. To work around this limitation, you can design your applications to:

* Open no more than one new window at once.
* Reuse existing windows to display different pages.
* Advise users on how to update their browser settings to allow multiple windows.
 
Share this answer
 
Comments
Aman Zoraiz 23-Apr-24 2:11am    
Thanks for responding

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900