Why does editing internal link text make a link open in a new window?

Jump to solution
zgambino-ce
Community Explorer

I've run into this problem recently where it seems like all the links to other content in my course are opening in a new window. They all seem to have the following attributes added to the link:

 

 class="inline_disabled"  target="_blank" rel="noopener noreferrer"

 

 

Doing some testing, I've found that if you use the "Link Options" on any internal link, it will automatically change it to treat it like an external link. This is because the URL is converted to a fully qualified URL.

image.png

Here's what the code looks like:

 

<p style="text-align: center;">
    <a class="inline_disabled" title="Welcome" href="https://MYSHCOOL.instructure.com/courses/215/modules/1033" target="_blank" rel="noopener noreferrer">Start Here</a>&nbsp;
</p>
<p style="text-align: center;">
    <a title="Welcome" href="/courses/215/modules/1033">Start Here Too</a>
</p>
<p style="text-align: center;">
    <a title="Welcome" href="/courses/215/modules/1033">Welcome</a>&nbsp;
</p>

 

The first link (Start Here) was edited using the "Link Options" menu.
The second link (Start Here Too) was created by highlighting the text first, then linking to the module.
The third link was inserted into the page without selecting anything first. If I were to edit this link to give it a better name, the HTML would look like the first (Start Here) link.

Is this supposed to happen like this? My IDs are currently struggling with this issue and although it can be fixed, it's a lot of manual editing of HTML that not all are comfortable with.

Is there a way to prevent this from happening?

Labels (1)
0 Likes
2 Solutions
James
Community Champion

@zgambino-ce 

How are you linking to internal course content? When I go to Links > Course Links and find a page, it puts in the full URL, not a relative link.

It's not the full URL that is causing it to be treated as an external link. It's the target="_blank" that is making it open in a new tab. You are correct that editing the options will add the target and rel attributes.

The question is why are you using Link Options for links within the course? Instead of changing the link URL itself, remove the link and then relink it if you need to change it. If you need to change the link text, just type over it without using link options.

Link Options make slightly more sense for external URLs than internal links, but forcing the addition of target and rel is undesired. Probably not to the level of bug (it's not documented that it won't do it) but certainly not the expected behavior.

View solution in original post

zgambino-ce
Community Explorer
Author

@James 
Well, I believe that adding the absolute url in the Link Options pane could be the symptom of the buggy behavior. It happens when you save any changes to a link using the Link Options pane. Even if you change the URL back to a relative url and not an absolute one.

I'm starting to think it's a real bug now.
I edited the "Welcome" link in my example and changed the text to "Welcomes" using the Link Options, making sure to re-set the URL to be a relative one.
Here's the result:

<p style="text-align: center;">
    <a class="inline_disabled" title="Welcome" href="/courses/215/modules/1033" target="_blank" rel="noopener noreferrer">Welcomes</a>&nbsp;
</p>

View solution in original post

0 Likes