في Xagent داخل XPages كيفية إعادة توجيه إلى نافذة جديدة؟

StackOverflow https://stackoverflow.com/questions/9020331

  •  14-11-2019
  •  | 
  •  

سؤال

لدي هذا Xagent مع يبدو أنه يعمل بشكل جيد ولكنه يفتحه في المتصفح الحالي.كيف يمكنني فتحه في نافذة جديدة؟

يتم تشغيل هذا الرمز بعد renderedResponse من XPAGE.

شكرا giveacodicetagpre.

هل كانت مفيدة؟

المحلول

Looks like you are trying to track when somebody clicks on the download link.

Without tracking the link would have been pointing directly at the file causing the browser to initiate the download and the user would stay on the current page. With the XAgent tracking in place the user is going to a different page in the application to do the tracking and initiate the download.

You could add a target of '_blank' to the initial link that is calling the XAgent. This will cause a new window/tab to open in the users browser but it will close once the download initiates.

Using this method of tracking the downloads will, however, remove the ability for the user of the site to be able to right click on your download link and do a 'save as'.

نصائح أخرى

For a download link you could also consider to just stream the file using the OutputStream (there only can be one: Writer or Stream!) to directly serve the bytes of the file to download. You need to set the MIME type in the header. If it is not a file type the browser can handle, the download dialog will appear anyway. Opening a new window is actually considered bad style these days. If a user wants a new Window there is Ctrl+Click and Shift+Click -> a decision you shouldn't make for them (which opens the can of worms of browser illiterate users).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top