• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Need assistance with JavaScipt page reference

Guest
Mar 24, 2013 Mar 24, 2013

Copy link to clipboard

Copied

[RH10, WebHelp Pro]

Hello,

A couple of years ago, someone here kindly provided a script that we use to give our users a feedback e-mail link from any page in the published output. We want to improve the script so that it returns a link not just to the specific page, but to the specific page PLUS the TOC pane.

Currently, the script defines a variable:

var str = location.href

The resulting link is:

http://projectname/robohelp/robo/server/general/projects/projectname/pagename.htm

What modification to the variable or the script is required to produce this link instead:

http://projectname/robohelp/robo/server/general/projects/projectname/default page#pagename.htm

The intention being that the added default page and hash mark would cause the link to open the page in the complete default frameset rather than just the page without the TOC?

Thank you

Views

650

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 25, 2013 Mar 25, 2013

Copy link to clipboard

Copied

Hi,

Check this script, this returns exactly that string: Get the CSH URL of a topic: http://www.wvanweelden.eu/blog/2012/08/03/get-csh-url-topic

Also, see Peter's site: http://www.grainge.org/pages/snippets/mailto.htm

Greet,

Willam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 25, 2013 Mar 25, 2013

Copy link to clipboard

Copied

It appears the script we are using is a variant of the one you linked to on Peter's site. It works well and  Javascript-wise, I don't feel competent to replace it.

Is it not possible simply to insert an additional parameter to the location.href variable so that it captures the default frameset as well as the page name?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 26, 2013 Mar 26, 2013

Copy link to clipboard

Copied

You can get the default frameset by

top.location.href

But that doesn't get the URL you want.

The function I linked to does just that. Instead of the document.location statement, reference the function:

var str=CSHURL();

And add the function CSHURL() to the master page or put it in a separate file and link that to your topics.

Greet,

Willam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 01, 2013 Apr 01, 2013

Copy link to clipboard

Copied

Sorry Willam, but can you walk me through the steps needed to "Add the function to the master page?"

I copied it to the clipboard and inserted it into the master page using the Insert>HTML>Advanced>Script command but after publishing the output it doesn't seem to be doing anything -- shouldn't I expect to see the URL there? It's just blank.

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2013 Apr 03, 2013

Copy link to clipboard

Copied

LATEST

Hi,

Somewhere, you have a script that produces a URL. I assume that you've added this script to the header or footer of the master page.

Now you need to do two things:

1. Add the CSHURL() function to the master page.

2. Amend the original script to use the new function.

To amend your script:

1. Open up your script.

2. Replace the line var str = location.href with var str=CSHURL();.

3. Save,

To add the function to the master page:

1. Open the master page.

2. Select the header or the footer of the master page.

3. Click Insert > HTML > Advanced > Script.

4. Copy the function CSHURL() to the script.

5. Close the dialog.

6. Save the master page. You should now see a red square in either the header or footer of the master page.

7. Make sure the master page is linked to all topics.

8. Generate your output.

Enjoy!

(

     Alternatively, you can also paste the function CSHURL() in the same location as the original script. Example:

     <script type="text/javascript">

     function myFunction() {

          //Your code here

     }

     function CSHURL() {//Paste the function above or below the other code.

     }

     </script>

)

Greet,

Willam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
RoboHelp Documentation
Download Adobe RoboHelp