I am working on a sharepoint online team site collection. and i have a discussion board list. now inside the AllItems.aspx
view, i added the following script:-
<script src="/assets/jquery-1.11.3.js" type="text/javascript"></script>
<script>
setTimeout(function() {
$('a[href*="mydiscussionboard"]').attr('target', '_blank');
}, 3000);
</script>
the purpose of the script is that whenever a user clicks on a discussion board item, the item should open in a new tab instead of opening it on the current tab. this will ease reading multiple items. and i had to define my script inside a counter otherwise the script will not work. seems the 3 seconds can ensure that the page is fully loaded. Now the script might not be the best thing to do !! but at-least it worked well, even when i embed the allitems view inside my modern page, the script worked.
But the only issue i am facing is that if the users do a paging on the items, or click on the load icon, or click on one of the tabs (such as "my discussions" or "what's hot") as follow:-
then the items' links will not open in new tabs.. so my question is how i can force my script to run after doing paging or partial updates??
I would avoid dictating browser behaviour for your users
?? now in my case i want to add the list view inside my modern page using the embed web part and usingIsDlg=1
. and if i do not modify the default behavioure when users click on the list items, then on the normal scenario, when a user click on the item link inside the embed web part, the whole page will be shown inside the web part without `IsDlg=1
.`. so i want to force the item to open in a separate tab..target=_blank
forces people to open in a new tab, regardless if they wanted to or not. Anyhow, let's see if I got this straight. You have a modern page with embed web part. This web part contains another page that has the list view that you are affecting. When they click a link in that list view, it opens within the embed web part. Is that correct?IsDlg=1
to my iframe url.. this will remove the unwanted components from the embedded page .. but if the user click on an item inside the embedded page, a new page will open within the embed web part, but the new page will not haveIsDlg=1
, so all the page's components such as header, left side navigation will be shown inside the embed web part, which looks totally wrong..so i want the item to open in new tab...