Skip to main content
Known Participant
September 24, 2009
Question

RoboHelp 8 HTML - Toolbar Button: Email with Link to Topic

  • September 24, 2009
  • 1 reply
  • 4749 views

Realized this would be better on this forum than the WebHelp forum:

Within a skin, I'd like to create a custom email button on my toolbar that would allow a user to email a direct link to a specific file in my RoboHelp project (a Share this Topic feature).

I thought it might be something like this:

window.location=('mailto:ENTERNAME@DOMAIN.COM?Subject=Useful Step-by-Step&body=This Step-by-Step may be helpful for you: ' + window.location)

but that just calls the toolbar, not the topic; the focus isn't on the correct window.

I have the following code that I could imbed on each topic page, but for consistency, I'd like to have this functionality on the toolbar instead. Has anyone done this or come across this before?

<p><script type="text/javascript">

var mailSubject = 'Useful Information';

var mailBody = 'This page might help: ' + location.href;

var mailDisplay = 'Click here for a demo.';

document.write(

'<a href="mailto:yourname@yourSite.com'

+ '?subject=' + escape(mailSubject)

+ '&body=' + escape(mailBody)

+ '">' + mailDisplay + '</a>'

);</script></p>

This topic has been closed for replies.

1 reply

Willam van Weelden
Inspiring
September 24, 2009

Hi,

You indeed need to focus on the correct window using window.parent.frames[1].frames[1].document.title (thanks to Philip Tory for this).

First, create a JavaScript file with the following function:

function email()
{
    var sEmail = prompt("Who do you want to e-mail?","Your e-mail adress");
    var sTitle = window.parent.frames[1].frames[1].document.title ;
    var sSubject = 'Useful Step-by-Step on the page '+sTitle+'.';
    var sHREF = window.parent.frames[1].frames[1].document.location;
    return('mailto:'+sEmail+'?Subject='+sSubject+'&body=This Step-by-Step on the page '+sTitle+' may be helpful for you: '+ escape(sHREF)+'.' );
}

Save the file as a baggage file in the root of the project.

Second, create a new button and in the action tab, add window.location=email() to the field onClick.

Third, choose External JavaScript file and select the baggage JavaScript file.

Output and you're all done.

Greet,

Willam

PS.: I added a prompt for the e-mail adress since I find that more user friendly. If you don't want it, replace the prompt with a 'hard coded'  address.

scmcgurrAuthor
Known Participant
September 24, 2009

Willam,

Thanks for your help. I'm not able to get that to work. I've got the .js file set up and saved as a baggage file and put the code in the OnClick and point to the .js file, but the button isn't functioning in the published version.

However, if I use the following code as inline JavaScript OnClick, I'm able to generate the email and the title of the Help file:

window.location=('mailto:ENTERNAME@aep.com?Subject=Useful Step-by-Step&body=This Asset Suite Step-by-Step may be helpful for you: ' + escape(window.parent.frames[1].frames[1].document.title))

It isn't providing an actual link to the topic, but it does provide the title of the topic, which is more than I was getting yesterday.

Thanks,

Sean

Message was edited by: Captiv8r - Corrected Willam's name.

Willam van Weelden
Inspiring
September 29, 2009

Hi,

It seems I'm a bit behind on the JavaScript , sorry about that... The document.location.href com object doesn't work anymore in XHTML, instead you have to use document.URL (match the case!).

Add the following statement in the onclick field:

window.location=('mailto:ENTERNAME@aep.com?Subject=Useful Step-by-Step&body=This Asset Suite Step-by-Step may be helpful for you: ' + escape(window.parent.frames[1].frames[1].document.title)+' on url: '+escape(window.parent.frames[1].frames[1].document.URL));

Greet,

Willam


For the good order..

The document.location.href com object doesn't work anymore in XHTML, instead you have to use document.URL (match the case!).

This is not true, my bad The document.location is a javascript object and document.URL is the HTML DOM object. You would use document.location to redirect someone to a page and you use document.URL to retreive the URL of the current document.

Greet,

Willam