Bug 51387 - when open a link with empty target frame, always create a new window
Summary: when open a link with empty target frame, always create a new window
Status: UNCONFIRMED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Frames (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-12-21 01:46 PST by ZhangYong
Modified: 2011-01-05 01:21 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ZhangYong 2010-12-21 01:46:35 PST
when a link looks like <a href="about.html">link</a>

it implies that the "target" of this link is empty. In IE and firefox, this link will be opened inside current frame.

And in webkit, the real target was reset to current document's target name.  If this target is "_blank", this link will be opened in a new window( which is not correct).
Comment 1 Alexey Proskuryakov 2010-12-21 11:53:33 PST
Thank you for the report! Do you have a test case or an example URL showing the problem? does this affect any live Web sites?
Comment 2 ZhangYong 2010-12-21 18:07:58 PST
try this:
http://club3.kdnet.net/dispbbs.asp?boardid=1&id=6659651
(note it is in Chinese!)

Click the page number (at the bottom of the page), it will open a new tab while IE&firefox will open in current tab.

I've fix this problem, code as below:

@@ -288,8 +288,11 @@ void FrameLoader::urlSelected(const ResourceRequest& request, const String& pass
         return;
 
     String target = passedTarget;
-    if (target.isEmpty())
+    if (target.isEmpty()) {
         target = m_frame->document()->baseTarget();
+        if (target == "_blank")
+            target = "_self";
+    }
 
     FrameLoadRequest frameRequest(request, target);
Comment 3 ZhangYong 2011-01-05 01:12:00 PST
sorry, the patch need a fix
 @@ -288,8 +288,11 @@ void FrameLoader::urlSelected(const ResourceRequest& request, const String& pass
          return;
 
      String target = passedTarget;
 -    if (target.isEmpty())
 +    if (target.isEmpty()) {
          target = m_frame->document()->baseTarget();
 +        if (target.isEmpty())
 +            target = "_self";
 +    }
 
      FrameLoadRequest frameRequest(request, target);

(In reply to comment #2)
> try this:
> http://club3.kdnet.net/dispbbs.asp?boardid=1&id=6659651
> (note it is in Chinese!)
> 
> Click the page number (at the bottom of the page), it will open a new tab while IE&firefox will open in current tab.
> 
> I've fix this problem, code as below:
> 
> @@ -288,8 +288,11 @@ void FrameLoader::urlSelected(const ResourceRequest& request, const String& pass
>          return;
> 
>      String target = passedTarget;
> -    if (target.isEmpty())
> +    if (target.isEmpty()) {
>          target = m_frame->document()->baseTarget();
> +        if (target == "_blank")
> +            target = "_self";
> +    }
> 
>      FrameLoadRequest frameRequest(request, target);
Comment 4 Alexey Proskuryakov 2011-01-05 01:21:09 PST
Would you be willing to submit a patch with a test case, as described in <http://webkit.org/coding/contributing.html>?