Issue with Link In App Page [SOLVED]

I've added a simple link to an app page:

section(getFormat("importantBold","HTML File"),hideable:true,hidden:false) {
			input "htmlFile", "bool", title: "Create a local HTML file for dashboards?", defaultValue: false, displayDuringSetup: false, required: false, width: 2, submitOnChange:true
			if(htmlFile) {
				fname = "costTable_${app.getLabel()}.html"
				fname = fname.replaceAll("\\s+","_")
				paragraph "<a href='/local/$fname' target='_blank' title='Open HTML file of main dashboard'>Link for HTML File"

For some reason, when I click "next" from that page, the app returns to the main screen, but also opens the link in a new tab. Am I doing something wrong?

Here are the page options:

dynamicPage(name: "advancedOptions",title:getFormat("header","Advanced Options and Utilities"), uninstall: false, install: false, nextPage: "mainPage")

@bertabcd1234 @thebearmay if you guys don't mind a look. See anything wrong?

Use href instead of paragraph

1 Like

Traditional case of RTFM

1 Like

So, this isn't working and I realized that href just take a page name that's inside the same app, right? I did try passing the URL, just to see, and no dice. I just get redirected to a blank page.

 href(name: "hrefHTMLPage", title: getFormat("importantBold","Click here to access the HTML file"),description: "", page: "/local/$fname", width:4,newLineAfter:true)

I will say, that creating the link in a paragraph worked like intended except the behavior when hitting "Next".

EDIT...figured it out. There's an optional "URL" parameter that I needed to use.

@bertabcd1234 could that parameter be added to the docs page?

1 Like

Maybe? :slight_smile: I'm not sure if that parameter is really intended for use on Hubitat or if it's just included for better compatibility with ported apps, so I'm hesitant to encourage its use if that's the case. (I'm not aware of any built-in apps that use it, not that linking to external websites happens much in any app.)

Is that the only problem with using the paragraph() approach? If so, target="_blank" is what's making it open in a new tab/window. Removing that should open it on the same page.

If you're saying that it's spontaneously opening even though you aren't actually clicking on anything, then I that is definitely odd (though it looks like you didn't close out the </a> tag, which some browsers might choke on but others might correct for you). If that is that case, there is a lot of dynamic code going on your example that makes it hard for someone else to use just that particular snippet. If you're able to reduce it all to some minimal case that demonstrates the problem, that might be easier to troubleshoot.

1 Like

This was the problem. The background below the link on the page was still showing the redirect URL. Added the close tag and bingo!

Thanks guys!

1 Like